home *** CD-ROM | disk | FTP | other *** search
- #ifndef __HeapGraph_h
- #define __HeapGraph_h
-
- #ifndef __stdio_h
- #include <stdio.h>
- #endif
-
-
- #ifdef HEAPGRAPH
-
- #ifndef __HeapGraph_Sendf_h
- #include "Sendf.h"
- #endif
-
- int HeapGraph_RedirectAllocFns( const char *filename);
- /*
- Use filename=NULL to send output to a unique file in Pipe:$.C_Debug
- to be picked up by the displayer.
-
- Returns 0 if succesful, otherwise non-zero.
-
- After this function is called, all calls to the ANSI C functions
- malloc, realloc, calloc and free will actually be redirected (by
- altering stubs at runtime) to internal HeapGraph functions.
-
- These functions will call the standard ANSI C functions, but also send
- data about the operation (malloc/free etc.) to 'filename', or a unique
- file in Pipe:$.C_Debug.* if 'filename' is NULL.
-
- This data can be picked up by the StubsHack !Displayer application to
- give a dynamic graphical display of your programs heap.
-
- If you want to call malloc/realloc/calloc/free directly, without sending
- data to 'filename', you can always use the function-pointers
- StubsHack_scl_malloc, StubsHack_scl_free, StubsHack_scl_realloc,
- StubsHack_scl_calloc defined in "StubsHack.StubsHack.h".
-
- If, for some reason, you want to know where malloc calls et al were sent to
- before you called 'HeapGraph_RedirectAllocFns', #include "HeapGraph.OldMalloc,
- and use HeapGraph_old_malloc etc.
- Normally HeapGraph_old_malloc == StubsHack_scl_malloc, but it won't if malloc
- was intercepted before you called 'HeapGraph_RedirectAllocFns'.
- */
-
-
-
- #define HeapGraph_Sendf HeapGraph__Sendf
- /*void HeapGraph_Sendf( char *fmt, ...);*/
- /* Sends text to the output file, which will be displayed by the displayer */
- /* Don't even *think* about sending characters between 1 and 4 - these will be */
- /* interpreted as messages about the heap. */
-
- /* Also, don't send messages of more than 127 chrs from a taskwindow - */
- /* - writing to a pipe from a taskwindow seems to hang when the pipe file length*/
- /* gets to 255. HeapGraph will wait until a pipe file is <128 bytes long */
- /* before writing to it if it is running in a taskwindow, giving you 127 bytes */
- /* grace... */
- /* You can call _Sendf without calling _RedirectAllocFns - this enables you to */
- /* send debugging data of your own without having all malloc's sent as well. */
-
-
- void HeapGraph_Init( const char *filename);
- /* You don't have to call this function - it is automatically called by both */
- /* _RedirectAllocFns and _Sendf the first time they are used if you haven't */
- /* called _Init already. */
- /* If filename==NULL (the usual), subsequent output will be sent to a unique */
- /* file in Pipe:$.C_Debug, otherwise 'filename' will be used. */
- /* You could use _Init to change the file to which subsequent data is sent. */
-
- extern int HeapGraph_reference;
- #define HeapGraph_SetReference( ref) HeapGraph_reference = (ref)
- /* HeapGraph_SetReference( x) will set the colour of subsequently malloced */
- /* blocks displayed by !HeapDisp to be 8+(x && 7). */
-
- /* Other stuff - probably not much use, but included here just in case. */
-
- extern char HeapGraph_filename[];
- /* The name of the file to which all HeapCheck output is sent. */
- /* Don't try to open this file yourself - if you want to write to it, */
- /* use HeapGraph_Sendf. */
- /* It is provided here in case you want to print it out or something, */
- /* *not* so you can open it etc. */
-
- FILE *HeapGraph_OpenPipeFile( void);
- void HeapGraph_ClosePipeFile( FILE *file);
- /* Use these if you really want to acess the pipe file yourself. */
- /* They check whether we are a task window etc. */
-
-
-
-
-
-
- #else
-
- /* These are for when HEAPGRAPH is not #defined. */
- /*
- They effectively remove all HeapGraph calls fom your source at the
- preprocess stage of compilation, so you can make HeapGraph or normal
- versions of your program simply by using cc ... -DHEAPGRAPH ...
- */
-
- #ifndef __HeapGraph_Dummyf_h
- #include "Dummyf.h"
- #endif
-
- #define HeapGraph_RedirectAllocFns( filename) 0
- #define HeapGraph_Init( filename)
- #define HeapGraph_SetReference( ref)
- #define HeapGraph_filename ""
- #define HeapGraph_OpenPipeFile() NULL
- #define HeapGraph_ClosePipeFile( file)
-
- #define HeapGraph_Sendf if (0) HeapGraph_Dummyf
- /* The file Dummyf contains the function 'Dummyf', which will only */
- /* be linked in if your compiler is performing no optimisations, eg */
- /* when you make a DDT version of your program. */
-
- #endif
-
-
-
-
- /* These are always used. */
- #define HeapGraph_SetReferenceDefault( ref) HeapGraph_SetReference( 0)
-
- typedef enum {
- HeapGraph_COLOUR = 1, /* For compatibility with ACELibs's Debug. */
- HeapGraph_MALLOC = 2,
- HeapGraph_REALLOC = 3,
- HeapGraph_FREE = 4
- }
- HeapGraph_codes;
- /* These codes signify the start of heap data to !HeapDisp. */
- /* Have a look at StubsHack.Sources.c.HeapGraph if you're */
- /* interested in the actual data format. */
-
-
- #endif
-