zero_cell.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * \file zero_cell.c
  3. *
  4. * \brief GIS Library - Zero cell buffer functions.
  5. *
  6. * (C) 2001-2008 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public License
  9. * (>=v2). Read the file COPYING that comes with GRASS for details.
  10. *
  11. * \author GRASS GIS Development Team
  12. *
  13. * \date 1999-2008
  14. */
  15. #include <grass/gis.h>
  16. /**
  17. * \brief Zero a raster CELL buffer.
  18. *
  19. * This routines assigns each member of the raster buffer array
  20. * <b>buf</b> to zero. It assumes that <b>buf</b> has been allocated
  21. * using <i>G_allocate_cell_buf.</i>
  22. *
  23. * \param[in] buf
  24. * \return
  25. */
  26. void G_zero_cell_buf(CELL * buf)
  27. {
  28. int i = G_window_cols();
  29. while (i--)
  30. *buf++ = 0;
  31. }
  32. /**
  33. * \brief Zero a raster buffer.
  34. *
  35. * This routines assigns each member of the raster buffer array
  36. * <b>rast</b> to zero. It assumes that <b>rast</b> has been allocated
  37. * using <i>G_allocate_cell_buf.</i>
  38. *
  39. * \param[in,out] rast
  40. * \param[in] data_type RASTER_MAP_TYPE
  41. * \return
  42. */
  43. void G_zero_raster_buf(void *rast, RASTER_MAP_TYPE data_type)
  44. {
  45. int i;
  46. unsigned char *ptr;
  47. /* assuming that the size of unsigned char is 1 byte */
  48. i = G_window_cols() * G_raster_size(data_type);
  49. ptr = (unsigned char *)rast;
  50. while (i--)
  51. *ptr++ = 0;
  52. }