00001 #include <stdlib.h>
00002 #include <grass/gis.h>
00003
00004
00017 void *G_malloc (size_t n)
00018 {
00019 void *buf;
00020
00021 if (n <= 0) n = 1;
00022
00023 buf = malloc(n);
00024 if(buf) return buf;
00025
00026 G_fatal_error ("G_malloc: out of memory");
00027 return NULL;
00028 }
00029
00030
00047 void *G_calloc (size_t m, size_t n)
00048 {
00049 void *buf;
00050
00051 if (m <= 0) m = 1;
00052 if (n <= 0) n = 1;
00053
00054 buf = calloc(m,n);
00055 if (buf) return buf;
00056
00057 G_fatal_error ("G_calloc: out of memory");
00058 return NULL;
00059 }
00060
00061
00082 void *G_realloc (void *buf, size_t n)
00083 {
00084 if (n <= 0) n = 1;
00085
00086 if (!buf) buf = malloc (n);
00087 else buf = realloc(buf,n);
00088
00089 if (buf) return buf;
00090
00091 G_fatal_error ("G_realloc: out of memory");
00092 return NULL;
00093 }
00094
00102 void G_free(void *buf)
00103 {
00104 free(buf);
00105 }