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

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:53