File: alloc.h

package info (click to toggle)
libhdf4 4.1r4-13
  • links: PTS
  • area: main
  • in suites: woody
  • size: 24,532 kB
  • ctags: 26,698
  • sloc: ansic: 207,298; fortran: 30,195; sh: 7,932; makefile: 7,472; cpp: 2,186; pascal: 1,407; asm: 1,027; yacc: 680; lex: 202; sed: 153
file content (53 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download | duplicates (4)
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
/* $Id: alloc.h,v 1.5 1996/04/23 02:40:06 georgev Exp $ */
#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_ */