Changeset 4300 for trunk/Ohana/src/libohana/include/ohana_allocate.h
- Timestamp:
- Jun 17, 2005, 12:16:29 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libohana/include/ohana_allocate.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libohana/include/ohana_allocate.h
r3903 r4300 5 5 # ifdef OHANA_MEMORY 6 6 7 void *ohana_malloc (char *file, int line, size_tsize);8 void *ohana_realloc (char *file, int line, void *in, size_tsize);7 void *ohana_malloc (char *file, int line, int Nelem, size_t esize); 8 void *ohana_realloc (char *file, int line, void *in, int Nelem, size_t esize); 9 9 void ohana_free (char *file, int line, void *in); 10 10 void ohana_memregister_func (char *file, int line, void *ptr); 11 11 void ohana_memdump_func (int mode); 12 void ohana_memcheck_func (int mode); 12 13 13 14 # define ohana_memregister(X) ohana_memregister_func (__FILE__, __LINE__, (X)); 15 # define ohana_memcheck(X) ohana_memcheck_func (X); 14 16 # define ohana_memdump(X) ohana_memdump_func (X); 15 17 16 # define ALLOCATE(X,T,S) \ 17 X = (T *) ohana_malloc (__FILE__, __LINE__, (unsigned)(MAX(((S)*((int)sizeof(T))),1))); \ 18 if (X == NULL) { \ 19 fprintf(stderr,"failed malloc at %d in %s\n", __LINE__, __FILE__);\ 20 exit (10); } 18 # define ALLOCATE(X,T,S) \ 19 X = (T *) ohana_malloc (__FILE__, __LINE__, (S), sizeof(T)) 21 20 # define REALLOCATE(X,T,S) \ 22 X = (T *) ohana_realloc(__FILE__, __LINE__, X,(unsigned)(MAX(((S)*((int)sizeof(T))),1))); \ 23 if (X == NULL) { \ 24 fprintf(stderr,"failed realloc at %d in %s\n", __LINE__, __FILE__);\ 25 exit (10); } 21 X = (T *) ohana_realloc(__FILE__, __LINE__, X, (S), sizeof(T)); 26 22 # define CHECK_REALLOCATE(X,T,S,N,D) \ 27 if ((N) >= (S)) { \ 28 S += D; \ 29 X = (T *) ohana_realloc(__FILE__, __LINE__, X,(unsigned)(MAX(((S)*((int)sizeof(T))),1))); \ 30 if (X == NULL) { \ 31 fprintf(stderr,"failed realloc increment at %d in %s\n", __LINE__, __FILE__);\ 32 exit (10); } } 23 if ((N) >= (S)) { S += D; \ 24 X = (T *) ohana_realloc(__FILE__, __LINE__, X, (S), sizeof(T)); } 33 25 # define free(X) ohana_free(__FILE__, __LINE__, X) 34 26 35 27 # else 36 28 # define ohana_memregister(X) /* NOP */ 29 # define ohana_memcheck(X) /* NOP */ 37 30 # define ohana_memdump(X) /* NOP */ 38 31 # endif /* OHANA_MEMORY */
Note:
See TracChangeset
for help on using the changeset viewer.
