Graph_close.c 660 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Close down the graphics processing. This gets called only at driver
  3. * termination time.
  4. */
  5. #ifndef __MINGW32__
  6. #include <unistd.h>
  7. #include <fcntl.h>
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #include <sys/mman.h>
  11. #endif
  12. #include <grass/gis.h>
  13. #include "pngdriver.h"
  14. static void unmap_file(void)
  15. {
  16. #ifndef __MINGW32__
  17. size_t size = HEADER_SIZE + png.width * png.height * sizeof(unsigned int);
  18. void *ptr = (char *)png.grid - HEADER_SIZE;
  19. if (!png.mapped)
  20. return;
  21. munmap(ptr, size);
  22. png.mapped = 0;
  23. #endif
  24. }
  25. void PNG_Graph_close(void)
  26. {
  27. write_image();
  28. if (png.mapped)
  29. unmap_file();
  30. else
  31. G_free(png.grid);
  32. }