bufs.c 772 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <grass/gis.h>
  2. #include <grass/raster.h>
  3. #include "ncb.h"
  4. /*
  5. allocate the i/o bufs
  6. the i/o bufs will be rotated by the read operation so that the
  7. last row read will be in the last i/o buf
  8. */
  9. int allocate_bufs(void)
  10. {
  11. int i;
  12. int bufsize;
  13. bufsize = (Rast_window_cols() + 2 * ncb.dist) * sizeof(DCELL);
  14. ncb.buf = (DCELL **) G_malloc(ncb.nsize * sizeof(DCELL *));
  15. for (i = 0; i < ncb.nsize; i++) {
  16. ncb.buf[i] = (DCELL *) G_malloc(bufsize);
  17. Rast_set_d_null_value(ncb.buf[i], Rast_window_cols() + 2 * ncb.dist);
  18. }
  19. return 0;
  20. }
  21. int rotate_bufs(void)
  22. {
  23. DCELL *temp;
  24. int i;
  25. temp = ncb.buf[0];
  26. for (i = 1; i < ncb.nsize; i++)
  27. ncb.buf[i - 1] = ncb.buf[i];
  28. ncb.buf[ncb.nsize - 1] = temp;
  29. return 0;
  30. }