GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
g3dalloc.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <sys/types.h>
4 #include <unistd.h>
5 #include <rpc/types.h>
6 #include <rpc/xdr.h>
7 #include "G3d_intern.h"
8 
9 /*---------------------------------------------------------------------------*/
10 
11 
24 void *G3d_malloc(int nBytes)
25 {
26  void *buf;
27 
28  if (nBytes <= 0)
29  nBytes = 1;
30  if ((buf = malloc(nBytes)) != NULL)
31  return buf;
32 
33  G3d_error("G3d_malloc: out of memory");
34  return (void *)NULL;
35 }
36 
37 
50 void *G3d_realloc(void *ptr, int nBytes)
51 {
52  if (nBytes <= 0)
53  nBytes = 1;
54  if ((ptr = realloc(ptr, nBytes)) != NULL)
55  return ptr;
56 
57  G3d_error("G3d_realloc: out of memory");
58  return (void *)NULL;
59 }
60 
61 
71 void G3d_free(void *buf)
72 {
73  free(buf);
74 }
void G3d_free(void *buf)
Same as free (ptr).
Definition: g3dalloc.c:71
void G3d_error(const char *msg,...)
Definition: g3derror.c:75
void * G3d_realloc(void *ptr, int nBytes)
Same as realloc (ptr, nBytes), except that in case of error G3d_error() is invoked.
Definition: g3dalloc.c:50
void * malloc(YYSIZE_T)
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
Definition: g3drange.c:62
return NULL
Definition: dbfopen.c:1394
void * G3d_malloc(int nBytes)
Same as malloc (nBytes), except that in case of error G3d_error() is invoked.
Definition: g3dalloc.c:24
void free(void *)