tilealloc.c 1.6 KB

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