Little conveniences

Jeffrey Hutzelman jhutz at cmu.edu
Thu Oct 1 12:55:35 EDT 2009


--On Thursday, October 01, 2009 11:22:38 AM -0400 ghudson at mit.edu wrote:

> The downside is that everyone knows what malloc() does, but not
> everyone will immediately know what k5alloc does.  It also uses
> krb5_error_code in a funny way, since the more common construction
> ("ret = k5alloc(size, &ptr);") can't be written as a C function due to
> the way C void pointers work.

Huh?  What's wrong with this?

  static inline krb5_error_code k5alloc(size_t size, void **ptrp)
  {
      *ptrp = calloc(size, 1);
      return (*ptrp == NULL) ? ENOMEM : 0;
  }

-- Jeff



More information about the krbdev mailing list