Index: /trunk/Ohana/src/libfits/include/fits.h
===================================================================
--- /trunk/Ohana/src/libfits/include/fits.h	(revision 3390)
+++ /trunk/Ohana/src/libfits/include/fits.h	(revision 3391)
@@ -22,6 +22,32 @@
 # endif /* NEWLINE */
 
+# ifndef MAX
+# define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
+# define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
+# endif
+
 /* general macros which should exist anyway! */
 # ifndef ALLOCATE
+# define ALLOCATE(X,T,S)  \
+  X = (T *) malloc ((unsigned)(MAX(((S)*((int)sizeof(T))),1))); \
+  if (X == NULL) { \
+    fprintf(stderr,"failed malloc at %s in %s\n", __LINE__, __FILE__);\
+    exit (10); } 
+# define REALLOCATE(X,T,S) \
+  X = (T *) realloc(X,(unsigned)(MAX(((S)*((int)sizeof(T))),1))); \
+  if (X == NULL) { \
+    fprintf(stderr,"failed realloc at %s in %s\n", __LINE__, __FILE__);\
+    exit (10); }
+# define CHECK_REALLOCATE(X,T,S,N,D) \
+  if ((N) >= (S)) { \
+    S += D; \
+    X = (T *) realloc(X,(unsigned)(MAX(((S)*((int)sizeof(T))),1))); \
+    if (X == NULL) { \
+      fprintf(stderr,"failed realloc increment at %s in %s\n", __LINE__, __FILE__);\
+      exit (10); } }
+# endif /* ALLOCATE */
+
+
+# if (0)
 # define ALLOCATE(X,T,S)  \
   X=(T *)malloc((unsigned) ((S)*sizeof(T)));\
@@ -38,5 +64,5 @@
        exit(0); \
     }
-# endif /* ALLOCATE */
+# endif /* old versions */
 
 # ifndef TRUE
@@ -49,4 +75,2 @@
 # endif
 
-# define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
-# define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
