GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tilealloc.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 
26 void *G3d_allocTilesType(G3D_Map * map, int nofTiles, int type)
27 {
28  void *tiles;
29 
30  tiles = G3d_malloc(map->tileSize * G3d_length(type) * nofTiles);
31  if (tiles == NULL) {
32  G3d_error("G3d_allocTilesType: error in G3d_malloc");
33  return NULL;
34  }
35 
36  return tiles;
37 }
38 
39 /*---------------------------------------------------------------------------*/
40 
41 
52 void *G3d_allocTiles(G3D_Map * map, int nofTiles)
53 {
54  void *tiles;
55 
56  tiles = G3d_allocTilesType(map, nofTiles, map->typeIntern);
57  if (tiles == NULL) {
58  G3d_error("G3d_allocTiles: error in G3d_allocTilesType");
59  return NULL;
60  }
61 
62  return tiles;
63 }
64 
65 /*---------------------------------------------------------------------------*/
66 
67 
77 void G3d_freeTiles(void *tiles)
78 {
79  G3d_free(tiles);
80 }
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_allocTiles(G3D_Map *map, int nofTiles)
Is equivalent to G3d_allocTilesType (map, nofTiles, G3d_fileTypeMap (map)).
Definition: tilealloc.c:52
void * G3d_allocTilesType(G3D_Map *map, int nofTiles, int type)
Allocates a vector of nofTiles tiles with the same dimensions as the tiles of map and large enough to...
Definition: tilealloc.c:26
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 G3d_freeTiles(void *tiles)
Is equivalent to G3d_free (tiles);
Definition: tilealloc.c:77
int G3d_length(int t)
Definition: g3dmisc.c:77