nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

alloc.h (562B)


      1 #ifndef ALLOC_H
      2 #define ALLOC_H
      3 
      4 #include <stdlib.h>
      5 #include <string.h>
      6 
      7 #include "deprecated.h"
      8 
      9 //#define alloc(x) malloc(x)
     10 
     11 // secure alloc(): zero bytes before use.
     12 // prevents heartbleed. Hilda
     13 static inline void *alloc(size_t x)
     14 {
     15 	void *y = malloc(x);
     16 	if (!(y == NULL)) memset(y, 0, x);
     17 	return y;
     18 }
     19 #define alloc_free(x) free(x)
     20 
     21 #ifdef DEPRECATED_FUNCTIONS_AVAILABLE
     22 static inline int _deprecated_ alloc_re(void **x, unsigned int m, unsigned int n)
     23 {
     24   void *y = realloc(*x, n);
     25   (void)m;
     26   if (y != NULL)
     27     *x = y;
     28   return !!y;
     29 }
     30 #endif
     31 
     32 #endif