Back to index

tetex-bin  3.0
mem.h
Go to the documentation of this file.
00001 /*  $Header$
00002 
00003     This is dvipdfm, a DVI to PDF translator.
00004     Copyright (C) 1998, 1999 by Mark A. Wicks
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019     
00020     The author may be contacted via the e-mail address
00021 
00022        mwicks@kettering.edu
00023 */
00024 
00025        
00026 #ifndef MEM_H
00027 #define MEM_H
00028 
00029 #include <stdlib.h>
00030 
00031 extern void *new (size_t size, char *function, int line);
00032 extern void *renew (void *p, size_t size, char *function, int line);
00033 extern void release (void *mem, char *function, int line);
00034 
00035 #ifdef MEM_DEBUG
00036 extern void mem_debug_init(void);
00037 extern FILE *debugfile;
00038 #define NEW(n,type) (type *)(new (((size_t) (n))*sizeof(type),__FUNCTION__,__LINE__))
00039 #define RENEW(p,n,type) (type *)(renew ((p),(n)*sizeof(type),__FUNCTION__,__LINE__))
00040 #define RELEASE(p) release ((p),__FUNCTION__,__LINE__)
00041 #define MEM_START {mem_debug_init();fprintf (debugfile, "Entered %s\n", __FUNCTION__);}
00042 #define MEM_END fprintf (debugfile, "Leaving %s\n", __FUNCTION__);
00043 #else /* MEM_DEBUG */
00044 #define MEM_START
00045 #define MEM_END
00046 #define NEW(n,type) (type *)(new (((size_t) (n))*sizeof(type),NULL,0))
00047 #define RENEW(p,n,type) (type *)(renew ((p),(n)*sizeof(type),NULL,0))
00048 #define RELEASE(p) release ((p),NULL,0)
00049 #endif /* MEM_DEBUG */
00050 #endif /* MEM_H */