/misc/src/release/graphviz-2.18-1/src/graphviz-2.18/lib/common/memory.h

Go to the documentation of this file.
00001 /* $Id: memory.h,v 1.3 2005/10/18 18:50:26 ellson Exp $ $Revision: 1.3 $ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /**********************************************************
00005 *      This software is part of the graphviz package      *
00006 *                http://www.graphviz.org/                 *
00007 *                                                         *
00008 *            Copyright (c) 1994-2004 AT&T Corp.           *
00009 *                and is licensed under the                *
00010 *            Common Public License, Version 1.0           *
00011 *                      by AT&T Corp.                      *
00012 *                                                         *
00013 *        Information and Software Systems Research        *
00014 *              AT&T Research, Florham Park NJ             *
00015 **********************************************************/
00016 
00017 #ifndef GV_MEMORY_H
00018 #define GV_MEMORY_H
00019 
00020 #include <stdlib.h>
00021 #ifdef HAVE_MALLOC_H
00022 #include <malloc.h>
00023 #endif
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 #ifdef DMALLOC
00030 #define NEW(t)           (t*)calloc(1,sizeof(t))
00031 #define N_NEW(n,t)       (t*)calloc((n),sizeof(t))
00032 #define GNEW(t)          (t*)malloc(sizeof(t))
00033 #define N_GNEW(n,t)      (t*)malloc((n)*sizeof(t))
00034 #define ALLOC(size,ptr,type) (ptr? (type*)realloc(ptr,(size)*sizeof(type)):(type*)malloc((size)*sizeof(type)))
00035 #define RALLOC(size,ptr,type) ((type*)realloc(ptr,(size)*sizeof(type)))
00036 #define ZALLOC(size,ptr,type,osize) (ptr? (type*)recalloc(ptr,(size)*sizeof(type)):(type*)calloc((size),sizeof(type)))
00037 #else
00038 #define NEW(t)           (t*)zmalloc(sizeof(t))
00039 #define N_NEW(n,t)       (t*)zmalloc((n)*sizeof(t))
00040 #define GNEW(t)          (t*)gmalloc(sizeof(t))
00041 #define N_GNEW(n,t)      (t*)gmalloc((n)*sizeof(t))
00042 #define ALLOC(size,ptr,type) (ptr? (type*)grealloc(ptr,(size)*sizeof(type)):(type*)gmalloc((size)*sizeof(type)))
00043 #define RALLOC(size,ptr,type) ((type*)grealloc(ptr,(size)*sizeof(type)))
00044 #define ZALLOC(size,ptr,type,osize) (ptr? (type*)zrealloc(ptr,size,sizeof(type),osize):(type*)zmalloc((size)*sizeof(type)))
00045 #endif
00046 
00047 
00048     extern void *zmalloc(size_t);
00049     extern void *zrealloc(void *, size_t, size_t, size_t);
00050     extern void *gmalloc(size_t);
00051     extern void *grealloc(void *, size_t);
00052 
00053 #ifdef __cplusplus
00054 }
00055 #endif
00056 
00057 #endif

Generated on Mon Mar 31 19:03:24 2008 for Graphviz by  doxygen 1.5.1