IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 17, 2005, 12:16:29 PM (21 years ago)
Author:
eugene
Message:

added corruption tests to ohana_allocate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libohana/include/ohana_allocate.h

    r3903 r4300  
    55# ifdef OHANA_MEMORY
    66
    7 void *ohana_malloc (char *file, int line, size_t size);
    8 void *ohana_realloc (char *file, int line, void *in, size_t size);
     7void *ohana_malloc (char *file, int line, int Nelem, size_t esize);
     8void *ohana_realloc (char *file, int line, void *in, int Nelem, size_t esize);
    99void  ohana_free (char *file, int line, void *in);
    1010void  ohana_memregister_func (char *file, int line, void *ptr);
    1111void  ohana_memdump_func (int mode);
     12void  ohana_memcheck_func (int mode);
    1213
    1314# define ohana_memregister(X) ohana_memregister_func (__FILE__, __LINE__, (X));
     15# define ohana_memcheck(X) ohana_memcheck_func (X);
    1416# define ohana_memdump(X) ohana_memdump_func (X);
    1517
    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))
    2120# 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));
    2622# 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)); }
    3325# define free(X) ohana_free(__FILE__, __LINE__, X)
    3426
    3527# else
    3628# define ohana_memregister(X) /* NOP */
     29# define ohana_memcheck(X) /* NOP */
    3730# define ohana_memdump(X) /* NOP */
    3831# endif /* OHANA_MEMORY */
Note: See TracChangeset for help on using the changeset viewer.