Annotation of embedaddon/ntp/include/ntp_malloc.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Define malloc and friends.
                      3:  */
                      4: #ifndef NTP_MALLOC_H
                      5: #define NTP_MALLOC_H
                      6: 
                      7: #ifdef HAVE_STDLIB_H
                      8: # include <stdlib.h>
                      9: #else
                     10: # ifdef HAVE_MALLOC_H
                     11: #  include <malloc.h>
                     12: # endif
                     13: #endif
                     14: 
                     15: /*
                     16:  * Deal with platform differences declaring alloca()
                     17:  * This comes nearly verbatim from:
                     18:  *
                     19:  * http://www.gnu.org/software/autoconf/manual/autoconf.html#Particular-Functions
                     20:  *
                     21:  * The only modifications were to remove C++ support and guard against
                     22:  * redefining alloca.
                     23:  */
                     24: #ifdef HAVE_ALLOCA_H
                     25: # include <alloca.h>
                     26: #elif defined __GNUC__
                     27: # ifndef alloca
                     28: #  define alloca __builtin_alloca
                     29: # endif
                     30: #elif defined _AIX
                     31: # ifndef alloca
                     32: #  define alloca __alloca
                     33: # endif
                     34: #elif defined _MSC_VER
                     35: # include <malloc.h>
                     36: # ifndef alloca
                     37: #  define alloca _alloca
                     38: # endif
                     39: #else
                     40: # include <stddef.h>
                     41: void * alloca(size_t);
                     42: #endif
                     43: 
                     44: #ifdef EREALLOC_IMPL
                     45: # define EREALLOC_CALLSITE     /* preserve __FILE__ and __LINE__ */
                     46: #else
                     47: # define EREALLOC_IMPL(ptr, newsz, filenm, loc) \
                     48:         realloc(ptr, (newsz))
                     49: #endif
                     50: 
                     51: #ifdef HAVE_STRINGS_H
                     52: # include <strings.h>
                     53: # define zero_mem(p, s)                bzero(p, s)
                     54: #endif
                     55: 
                     56: #ifndef zero_mem
                     57: # define zero_mem(p, s)                memset(p, 0, s)
                     58: #endif
                     59: #define ZERO(var)              zero_mem(&(var), sizeof(var))
                     60: 
                     61: #endif /* NTP_MALLOC_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>