Graphviz  2.41.20171026.1811
memory.h
Go to the documentation of this file.
1 /* $Id$ $Revision$ */
2 /* vim:set shiftwidth=4 ts=8: */
3 
4 /*************************************************************************
5  * Copyright (c) 2011 AT&T Intellectual Property
6  * All rights reserved. This program and the accompanying materials
7  * are made available under the terms of the Eclipse Public License v1.0
8  * which accompanies this distribution, and is available at
9  * http://www.eclipse.org/legal/epl-v10.html
10  *
11  * Contributors: See CVS logs. Details at http://www.graphviz.org/
12  *************************************************************************/
13 
14 #ifndef GV_MEMORY_H
15 #define GV_MEMORY_H
16 
17 #include <stdlib.h>
18 #ifdef HAVE_MALLOC_H
19 #include <malloc.h>
20 #endif
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #ifdef DMALLOC
27 #define NEW(t) (t*)calloc(1,sizeof(t))
28 #define N_NEW(n,t) (t*)calloc((n),sizeof(t))
29 #define GNEW(t) (t*)malloc(sizeof(t))
30 #define N_GNEW(n,t) (t*)malloc((n)*sizeof(t))
31 #define ALLOC(size,ptr,type) (ptr? (type*)realloc(ptr,(size)*sizeof(type)):(type*)malloc((size)*sizeof(type)))
32 #define RALLOC(size,ptr,type) ((type*)realloc(ptr,(size)*sizeof(type)))
33 #define ZALLOC(size,ptr,type,osize) (ptr? (type*)recalloc(ptr,(size)*sizeof(type)):(type*)calloc((size),sizeof(type)))
34 #else
35 #define NEW(t) (t*)zmalloc(sizeof(t))
36 #define N_NEW(n,t) (t*)zmalloc((n)*sizeof(t))
37 #define GNEW(t) (t*)gmalloc(sizeof(t))
38 
39 #define N_GNEW(n,t) (t*)gmalloc((n)*sizeof(t))
40 #define N_GGNEW(n,t) (t*)malloc((n)*sizeof(t))
41 #define ALLOC(size,ptr,type) (ptr? (type*)grealloc(ptr,(size)*sizeof(type)):(type*)gmalloc((size)*sizeof(type)))
42 #define RALLOC(size,ptr,type) ((type*)grealloc(ptr,(size)*sizeof(type)))
43 #define ZALLOC(size,ptr,type,osize) (ptr? (type*)zrealloc(ptr,size,sizeof(type),osize):(type*)zmalloc((size)*sizeof(type)))
44 #endif
45 #ifdef GVDLL
46 #define extern __declspec(dllexport)
47 #else
48 #ifdef _WIN32
49 #ifndef GVC_EXPORTS
50 #define extern __declspec(dllimport)
51 #endif
52 #endif
53 
54 #endif
55 
56  extern void *zmalloc(size_t);
57  extern void *zrealloc(void *, size_t, size_t, size_t);
58  extern void *gmalloc(size_t);
59  extern void *grealloc(void *, size_t);
60 #undef extern
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif
void * zmalloc(size_t nbytes)
Definition: memory.c:20
void * grealloc(void *ptr, size_t size)
Definition: memory.c:54
void * gmalloc(size_t nbytes)
Definition: memory.c:42
void * zrealloc(void *ptr, size_t size, size_t elt, size_t osize)
Definition: memory.c:30