alloc.c

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include "gis.h"
00003 
00004 
00017 void *G_malloc (int n)
00018 {
00019     void *buf;
00020 
00021     if (n <= 0) n = 1;  /* make sure we get a valid request */
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 (int m,int n)
00048 {
00049     void *buf;
00050 
00051     if (m <= 0) m = 1;  /* make sure we get a valid requests */
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,int n)
00083 {
00084     if (n <= 0) n = 1;  /* make sure we get a valid request */
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 }

Generated on Sat Jul 22 22:06:14 2006 for GRASS by  doxygen 1.4.7