RCS Header: /home/amb/CVS/cxref/src/memory.c,v 1.13 2004-06-19 19:03:13 amb Exp
C Cross Referencing & Documentation tool. Version 1.6.
Memory management functions
The amount of debugging, non-zero for totals, 2 for logging, 4 for printing each call.
The size of each of the heap allocations
#define HEAP_INC 8192
The size of a string that is large enough to have it's own mallocation.
A private memory heap is used to reduce the number of malloc calls that are made, the Heap type is a pointer to this.
See: | Type struct _Heap |
A structure containing all of the information about the private heap in a linked list.
struct _Heap
struct _Heap | |
{ | |
char* mem; | The memory that is private to the heap. |
Heap next; | The next Heap structure. |
} |
Local variable to control the usage of the private heap; the first segment of memory on the private heap.
Used in: | TidyMemory() | |
add_to_heap() |
the amount of space left in the current heap segment.
Used in: | TidyMemory() | |
get_space() |
A function to concatenate a number of strings.
char* ConcatStrings ( int n, char* s, ... )
Any of the strings that are inputs can be NULL, in this case they are quietly ignored.
A function to copy a string on the local private memory heap.
Prototyped in: | memory.h | |
Calls: | get_space() | memory.c |
strcpy(), strlen() | ||
Called by: | ParseConfigFile() | cxref.c |
SeenFileChange() | preproc.c | |
SplitComment() | comment.c | |
yylex() | parse-lex.c | |
yyparse() | parse-yacc.c |
Prints out the number of mallocs / reallocs and frees.
void PrintMemoryStatistics ( void )
Prototyped in: | memory.h | |
Called by: | main() | cxref.c |
A replacement calloc() function.
void* SafeCalloc ( unsigned int n, unsigned int size, char* file, int line )
Prototyped in: | memory.h | |
Calls: | calloc(), printf() | |
Called by: | NewDefineType() | preproc.c |
NewFile() | file.c | |
NewFunctionType() | func.c | |
NewIncludeType() | preproc.c | |
NewStringList() | slist.c | |
NewStringList2() | slist.c | |
NewStructUnionType() | type.c | |
NewTypedefType() | type.c | |
NewVariableType() | var.c |
A replacement free() function.
void SafeFree ( void* ptr, char* file, int line )
A replacement malloc() function.
void* SafeMalloc ( unsigned int size, char* file, int line )
Prototyped in: | memory.h | |
Calls: | malloc(), printf() | |
Called by: | AddToStringList() | slist.c |
AddToStringList2() | slist.c | |
CopyStructUnion() | type.c | |
ParseConfigFile() | cxref.c | |
ParseOptions() | cxref.c | |
SafeMallocString() | memory.c | |
SeenComment() | comment.c | |
SeenFileChange() | preproc.c | |
SeenStructUnionComp() | type.c | |
UpScope() | var.c | |
add_to_heap() | memory.c | |
html() | html.c | |
latex() | latex.c | |
main() | cxref.c | |
push() | parse-yacc.c | |
rtf() | rtf.c | |
sgml() | sgml.c |
A function to copy a string on the public global heap.
char* SafeMallocString ( char* x, char* file, int line )
A replacement realloc() function.
void* SafeRealloc ( void* ptr, unsigned int size, char* file, int line )
Prototyped in: | memory.h | |
Calls: | printf(), realloc() | |
Called by: | AddToStringList() | slist.c |
AddToStringList2() | slist.c | |
ParseConfigFile() | cxref.c | |
ParseOptions() | cxref.c | |
SeenComment() | comment.c | |
SeenFileChange() | preproc.c | |
SeenStructUnionComp() | type.c | |
SetCurrentComment() | comment.c | |
UpScope() | var.c | |
html() | html.c | |
latex() | latex.c | |
main() | cxref.c | |
push() | parse-yacc.c | |
rtf() | rtf.c | |
sgml() | sgml.c |
Tidies up the local heap of memory.
Prototyped in: | memory.h | |
Calls: | SafeFree() | memory.c |
Called by: | main() | cxref.c |
References Variables: | first | memory.c |
heap_left | memory.c |
Add some bytes to the privately maintained memory heap.
static Heap add_to_heap ( unsigned int l )
Prototyped in: | memory.c | |
Calls: | SafeMalloc() | memory.c |
Called by: | get_space() | memory.c |
References Variables: | first | memory.c |
A function to get some memory for a string, allocate a new heap structure if needed.
static char* get_space ( unsigned int l )
Prototyped in: | memory.c | |
Calls: | add_to_heap() | memory.c |
Called by: | ConcatStrings() | memory.c |
CopyString() | memory.c | |
References Variables: | heap_left | memory.c |