1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF. The full HDF copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at *
* http://hdfgroup.org/products/hdf4/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* $Id: alloc.h 4933 2007-09-08 03:33:59Z bmribler $ */
#ifndef _ALLOC_H_
#define _ALLOC_H_
#ifndef NO_STDLIB
#include <stdlib.h>
#else
extern char *malloc();
extern char *realloc();
#ifndef NULL
#define NULL 0
#endif /* !NULL */
#endif /* !NO_STDLIB */
#ifdef HDF
#define Alloc(theNum, theType) \
(theType *)HDmalloc(sizeof(theType) * (theNum))
#else
#define Alloc(theNum, theType) \
(theType *)malloc(sizeof(theType) * (theNum))
#endif
#ifndef NO_STDLIB
#ifdef HDF
#define Free(ptr) HDfree((VOIDP)ptr)
#else
#define Free(ptr) free(ptr)
#define HDfree(ptr) free(ptr)
#endif
#else
/* old style free */
#ifdef HDF
#define Free(ptr) (void)HDfree((char *)ptr)
#else
#define Free(ptr) (void)free((char *)ptr)
#define HDfree(ptr) (void)free((char *)ptr)
#endif
#endif /* !NO_STDLIB */
/* We need to define these to standard ones when HDF is not defined */
#ifndef HDF
#define HDcalloc(nelem, elsize) calloc(nelem,elsize)
#define HDmemset(dst,c,n) memset(dst,c,n)
#define HDrealloc(p,s) realloc(p,s)
#define HDmalloc(s) malloc(s)
#endif /* HDF */
#define ARRAYLEN(arr) (sizeof(arr)/sizeof(arr[0]))
#endif /* !_ALLOC_H_ */
|