Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

mcw_malloc.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006    
00007 #ifndef _MCW_MALLOC_HEADER_
00008 #define _MCW_MALLOC_HEADER_
00009 
00010 /*----- 24 Jan 2001: modified slightly to add some comments, and
00011                      to fit in with the hashtable-ized mcw_malloc.c -----*/
00012 
00013 #include <stdlib.h>
00014 #include <stdio.h>
00015 #include <X11/Intrinsic.h>
00016 
00017 #include "machdep.h"
00018 
00019 /*---------------------------------------------------------------------------*/
00020 #ifdef DONT_USE_MCW_MALLOC
00021 
00022 #define MCW_MALLOC_enabled 0
00023 
00024 #define MCW_MALLOC_status  NULL
00025 
00026 #undef  mcw_malloc
00027 #define mcw_malloc  malloc
00028 
00029 #undef  mcw_realloc
00030 #define mcw_realloc realloc
00031 
00032 #undef  mcw_calloc
00033 #define mcw_calloc  calloc
00034 
00035 #undef  mcw_free
00036 #define mcw_free    free
00037 
00038 /*---------------------------------------------------------------------------*/
00039 #else
00040 
00041 #define USING_MCW_MALLOC
00042 
00043 /*-- define macros to replace the source code's use of malloc(), etc. --*/
00044 
00045 #undef malloc
00046 #undef realloc
00047 #undef calloc
00048 #undef free
00049 
00050 #define malloc(a)     mcw_malloc((a),__FILE__,__LINE__)
00051 #define realloc(a,b)  mcw_realloc((a),(b),__FILE__,__LINE__)
00052 #define calloc(a,b)   mcw_calloc((a),(b),__FILE__,__LINE__)
00053 #define free          mcw_free
00054 
00055 /*-- prototypes for interface functions --*/
00056 
00057 extern void   enable_mcw_malloc() ;
00058 extern void * mcw_malloc( size_t , char * , int ) ;
00059 extern void * mcw_realloc( void * , size_t , char * , int ) ;
00060 extern void * mcw_calloc( size_t , size_t , char * , int ) ;
00061 extern void   mcw_free( void * ) ;
00062 
00063 extern char * mcw_malloc_status(const char *,int) ;
00064 extern void   mcw_malloc_dump(void) ;
00065 extern int    mcw_malloc_enabled(void) ;
00066 extern void   pause_mcw_malloc(void);
00067 extern void   resume_mcw_malloc(void);
00068 extern int    mcw_malloc_paused(void);
00069 
00070 /*-- how to check if the tracking routines are working --*/
00071 
00072 #define MCW_MALLOC_enabled mcw_malloc_enabled()
00073 
00074 #define MCW_MALLOC_status  mcw_malloc_status(__FILE__,__LINE__)
00075 
00076 /*-- do the same macro thing for the Xt library functions --*/
00077 
00078 #undef XtMalloc
00079 #undef XtRealloc
00080 #undef XtFree
00081 #undef XtCalloc
00082 
00083 #define XtMalloc(a)     mcw_XtMalloc((a),__FILE__,__LINE__)
00084 #define XtRealloc(a,b)  mcw_XtRealloc((char *)(a),(b),__FILE__,__LINE__)
00085 #define XtCalloc(a,b)   mcw_XtCalloc((a),(b),__FILE__,__LINE__)
00086 #define XtFree(a)       mcw_XtFree((char *)(a))
00087 
00088 extern char * mcw_XtMalloc( Cardinal , char * ,  int ) ;
00089 extern char * mcw_XtRealloc( char * , Cardinal , char * ,  int ) ;
00090 extern char * mcw_XtCalloc( Cardinal , Cardinal , char * ,  int ) ;
00091 extern void   mcw_XtFree( char * ) ;
00092 
00093 #endif /* DONT_USE_MCW_MALLOC */
00094 /*---------------------------------------------------------------------------*/
00095 
00096 /*-- some macros used in various AFNI places --*/
00097 
00098 #define myXtFree(xp)  (XtFree((char *)(xp)) , (xp)=NULL)
00099 #define myXtNew(type) ((type *) XtCalloc(1,(Cardinal) sizeof(type)))
00100 #define myfree(xp)    (free((xp)) , (xp)=NULL)
00101 
00102 #endif /* _MCW_MALLOC_HEADER_ */
 

Powered by Plone

This site conforms to the following standards: