Restored work-around for hangs when trying to use disk-based handlers
[tangerine.git] / tools / cxref / memory.h
blob6c6a8f46a6b63effed5bd010a8d524a4eaffd3ea
1 /***************************************
2 $Header$
4 C Cross Referencing & Documentation tool. Version 1.0
6 Memory management functions
7 ******************/ /******************
8 Written by Andrew M. Bishop
10 This file Copyright 1995,96 Andrew M. Bishop
11 It may be distributed under the GNU Public License, version 2, or
12 any higher version. See section COPYING of the GNU Public license
13 for conditions under which this file may be redistributed.
14 ***************************************/
17 #ifndef MEMORY_H
18 #define MEMORY_H /*+ To stop multiple inclusions. +*/
20 /*+ malloc(), calloc(), realloc() and free() replacements +*/
22 #define Malloc(s) SafeMalloc ( s,__FILE__,__LINE__)
23 #define Calloc(n,s) SafeCalloc (n,s,__FILE__,__LINE__)
24 #define Realloc(p,s) SafeRealloc(p,s,__FILE__,__LINE__)
25 #define Free(p) SafeFree (p ,__FILE__,__LINE__)
27 void* SafeMalloc(unsigned int size,char* file,int line);
28 void* SafeCalloc(unsigned int n,unsigned int size,char* file,int line);
29 void* SafeRealloc(void* ptr,unsigned int size,char* file,int line);
30 void SafeFree(void* ptr,char* file,int line);
32 /*+ String manipulation functions on public heap +*/
34 #define MallocString(p) SafeMallocString (p,__FILE__,__LINE__)
36 char* SafeMallocString(char* x,char* file,int line);
38 /* String manipulation functions on private memory heap */
40 char* CopyString(char* x);
41 char* ConcatStrings(int n,char* s, ...);
42 void TidyMemory(void);
44 /* Internal Functions */
46 void PrintMemoryStatistics(void);
48 /* Memory handling concepts *
50 0) Memory that is private only lasts for the period of parsing the file (including cross-referencing).
51 1) All storage for File, Function etc. data types is to be public (permanent).
52 2) Data used during parsing is to be private.
53 3) Copying of strings is only to be performed if needed, all of the following use the private heap.
54 a) Lex code passes constant values to Yacc code where possible.
55 b) Lex code is to pass copies of strings to Yacc code since it disappears otherwise.
56 c) Yacc code concatanates strings for internal manipulation.
57 d) Lex passes pointers (not copies) to comment.c where private copies are made.
58 4) Comments from comment.c are passed as private data, the receiver must Malloc a copy of them.
60 * Memory handling concepts */
62 #endif