gpg_err_code_from_errno usage

Nikos Mavrogiannopoulos n.mavrogiannopoulos at
Sat Mar 11 06:54:54 CET 2006

 I've noticed quite big parts of libgcrypt use the following

    array = gcry_calloc (strlen (elems) + 1, sizeof (*array));
    if (! array)
      err = gpg_err_code_from_errno (errno);

But how can you be sure that calloc() (or in that case gcry_calloc)
will set the errno? calloc is a library call which may or may not use
a system call. Even if it works on some systems, this is a very
non-portable construction, which will result in no error checking in
systems that do not set errno.

More information about the Gcrypt-devel mailing list