tilealloc.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 "raster3d_intern.h"
  8. /*---------------------------------------------------------------------------*/
  9. /*!
  10. * \brief
  11. *
  12. * Allocates a vector of <em>nofTiles</em> tiles with the same dimensions
  13. * as the tiles of <em>map</em> and large enough to store cell-values of
  14. * <em>type</em>.
  15. *
  16. * \param map
  17. * \param nofTiles
  18. * \param type
  19. * \return void * : a pointer to the vector ... if successful,
  20. * NULL ... otherwise.
  21. */
  22. void *Rast3d_alloc_tiles_type(RASTER3D_Map * map, int nofTiles, int type)
  23. {
  24. void *tiles;
  25. tiles = Rast3d_malloc(map->tileSize * Rast3d_length(type) * nofTiles);
  26. if (tiles == NULL) {
  27. Rast3d_error("Rast3d_alloc_tiles_type: error in Rast3d_malloc");
  28. return NULL;
  29. }
  30. return tiles;
  31. }
  32. /*---------------------------------------------------------------------------*/
  33. /*!
  34. * \brief
  35. *
  36. * Is equivalent to Rast3d_alloc_tiles_type (map, nofTiles, Rast3d_file_type_map (map)).
  37. *
  38. * \param map
  39. * \param nofTiles
  40. * \return void *
  41. */
  42. void *Rast3d_alloc_tiles(RASTER3D_Map * map, int nofTiles)
  43. {
  44. void *tiles;
  45. tiles = Rast3d_alloc_tiles_type(map, nofTiles, map->typeIntern);
  46. if (tiles == NULL) {
  47. Rast3d_error("Rast3d_alloc_tiles: error in Rast3d_alloc_tiles_type");
  48. return NULL;
  49. }
  50. return tiles;
  51. }
  52. /*---------------------------------------------------------------------------*/
  53. /*!
  54. * \brief
  55. *
  56. * Is equivalent to <tt>Rast3d_free (tiles);</tt>
  57. *
  58. * \param tiles
  59. * \return void
  60. */
  61. void Rast3d_free_tiles(void *tiles)
  62. {
  63. Rast3d_free(tiles);
  64. }