OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
xmalloc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004, Remik Ziemlinski <first d0t surname att n0aa d0t g0v>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2, or (at your option)
7  any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; see the file COPYING.
16  If not, write to the Free Software Foundation,
17  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef XMALLOC_H
21 #define XMALLOC_H 1
22 
23 #include "common.h"
24 
25 #ifdef __cplusplus
26 #define BEGIN_C_DECLS extern "C" {
27 #define END_C_DECLS }
28 #else
29 #define BEGIN_C_DECLS
30 #define END_C_DECLS
31 #endif
32 
33 #define XCALLOC(type, num) \
34 ((type*) xcalloc ((size_t)(num), (size_t)sizeof(type)))
35 
36 #define XMALLOC(type, num) \
37 ((type*) xmalloc((size_t)((num) * sizeof(type))))
38 
39 #define XREALLOC(type, p, num) \
40 ((type*) xrealloc ((p), (size_t)((num) * sizeof(type))))
41 
42 #define XFREE(stale) \
43 do { \
44 if (stale) { free(stale); stale=0; } \
45 } while (0)
46 
48 
49 extern void* xcalloc(size_t num, size_t size);
50 extern void* xmalloc(size_t num);
51 extern void* xrealloc(void* p, size_t num);
52 
54 
55 #endif
void * xrealloc(void *p, size_t num)
Definition: xmalloc.c:34
#define BEGIN_C_DECLS
Definition: xmalloc.h:29
void * xmalloc(size_t num)
Definition: xmalloc.c:23
BEGIN_C_DECLS void * xcalloc(size_t num, size_t size)
Definition: xmalloc.c:50
float p[MODELMAX]
Definition: atrem_corl1.h:131
#define END_C_DECLS
Definition: xmalloc.h:30