IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3391


Ignore:
Timestamp:
Mar 7, 2005, 6:19:29 PM (21 years ago)
Author:
eugene
Message:

added new versions of ALLOCATE (see libohana)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libfits/include/fits.h

    r2415 r3391  
    2222# endif /* NEWLINE */
    2323
     24# ifndef MAX
     25# define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
     26# define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
     27# endif
     28
    2429/* general macros which should exist anyway! */
    2530# ifndef ALLOCATE
     31# define ALLOCATE(X,T,S)  \
     32  X = (T *) malloc ((unsigned)(MAX(((S)*((int)sizeof(T))),1))); \
     33  if (X == NULL) { \
     34    fprintf(stderr,"failed malloc at %s in %s\n", __LINE__, __FILE__);\
     35    exit (10); }
     36# define REALLOCATE(X,T,S) \
     37  X = (T *) realloc(X,(unsigned)(MAX(((S)*((int)sizeof(T))),1))); \
     38  if (X == NULL) { \
     39    fprintf(stderr,"failed realloc at %s in %s\n", __LINE__, __FILE__);\
     40    exit (10); }
     41# define CHECK_REALLOCATE(X,T,S,N,D) \
     42  if ((N) >= (S)) { \
     43    S += D; \
     44    X = (T *) realloc(X,(unsigned)(MAX(((S)*((int)sizeof(T))),1))); \
     45    if (X == NULL) { \
     46      fprintf(stderr,"failed realloc increment at %s in %s\n", __LINE__, __FILE__);\
     47      exit (10); } }
     48# endif /* ALLOCATE */
     49
     50
     51# if (0)
    2652# define ALLOCATE(X,T,S)  \
    2753  X=(T *)malloc((unsigned) ((S)*sizeof(T)));\
     
    3864       exit(0); \
    3965    }
    40 # endif /* ALLOCATE */
     66# endif /* old versions */
    4167
    4268# ifndef TRUE
     
    4975# endif
    5076
    51 # define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
    52 # define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
Note: See TracChangeset for help on using the changeset viewer.