Little conveniences
    Danilo Almeida 
    dalmeida at MIT.EDU
       
    Sat Oct  3 18:59:54 EDT 2009
    
    
  
Greg,
Wrt the out pointer argument casting issues, you can do something like this:
  #define k5alloc(Size, PointerToPointer) \
      ( !((*(PointerToPointer)) = calloc(Size, 1)) ? ENOMEM : 0 )
For C++, you need a cast in there, so a template does the trick:
  template<typename T> int k5alloc(size_t Size, T* PointerToPointer)
  {
      return ( !((*(PointerToPointer)) = (T) calloc(Size, 1)) ? ENOMEM : 0
);
  }
Then you can always just do:
  ret = k5alloc(sizeof(foo), &foo);
  if (ret) ...
- Danilo
    
    
More information about the krbdev
mailing list