diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-12-02 09:01:21 +0000 |
---|---|---|
committer | <> | 2014-12-04 16:11:25 +0000 |
commit | bdab5265fcbf3f472545073a23f8999749a9f2b9 (patch) | |
tree | c6018dd03dea906f8f1fb5f105f05b71a7dc250a /include/ntp_malloc.h | |
download | ntp-bdab5265fcbf3f472545073a23f8999749a9f2b9.tar.gz |
Imported from /home/lorry/working-area/delta_ntp/ntp-dev-4.2.7p482.tar.gz.ntp-dev-4.2.7p482
Diffstat (limited to 'include/ntp_malloc.h')
-rw-r--r-- | include/ntp_malloc.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/include/ntp_malloc.h b/include/ntp_malloc.h new file mode 100644 index 0000000..4cde62e --- /dev/null +++ b/include/ntp_malloc.h @@ -0,0 +1,61 @@ +/* + * Define malloc and friends. + */ +#ifndef NTP_MALLOC_H +#define NTP_MALLOC_H + +#ifdef HAVE_STDLIB_H +# include <stdlib.h> +#else +# ifdef HAVE_MALLOC_H +# include <malloc.h> +# endif +#endif + +/* + * Deal with platform differences declaring alloca() + * This comes nearly verbatim from: + * + * http://www.gnu.org/software/autoconf/manual/autoconf.html#Particular-Functions + * + * The only modifications were to remove C++ support and guard against + * redefining alloca. + */ +#ifdef HAVE_ALLOCA_H +# include <alloca.h> +#elif defined __GNUC__ +# ifndef alloca +# define alloca __builtin_alloca +# endif +#elif defined _AIX +# ifndef alloca +# define alloca __alloca +# endif +#elif defined _MSC_VER +# include <malloc.h> +# ifndef alloca +# define alloca _alloca +# endif +#else +# include <stddef.h> +void * alloca(size_t); +#endif + +#ifdef EREALLOC_IMPL +# define EREALLOC_CALLSITE /* preserve __FILE__ and __LINE__ */ +#else +# define EREALLOC_IMPL(ptr, newsz, filenm, loc) \ + realloc(ptr, (newsz)) +#endif + +#ifdef HAVE_STRINGS_H +# include <strings.h> +# define zero_mem(p, s) bzero(p, s) +#endif + +#ifndef zero_mem +# define zero_mem(p, s) memset(p, 0, s) +#endif +#define ZERO(var) zero_mem(&(var), sizeof(var)) + +#endif /* NTP_MALLOC_H */ |