GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pngdriver/Graph_close.c
Go to the documentation of this file.
1 /*
2  * Close down the graphics processing. This gets called only at driver
3  * termination time.
4  */
5 
6 #ifndef __MINGW32__
7 #include <unistd.h>
8 #include <fcntl.h>
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <sys/mman.h>
12 #endif
13 
14 #include <grass/gis.h>
15 #include "pngdriver.h"
16 
17 static void unmap_file(void)
18 {
19 #ifndef __MINGW32__
20  size_t size = HEADER_SIZE + width * height * sizeof(unsigned int);
21  void *ptr = (char *)grid - HEADER_SIZE;
22 
23  if (!mapped)
24  return;
25 
26  munmap(ptr, size);
27 
28  mapped = 0;
29 #endif
30 }
31 
32 void PNG_Graph_close(void)
33 {
34  write_image();
35 
36  if (mapped)
37  unmap_file();
38  else
39  G_free(grid);
40 }
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
#define HEADER_SIZE
Definition: cairodriver.h:17
void PNG_Graph_close(void)
tuple width
unsigned char * grid
tuple size
value.Bind(wx.EVT_TEXT, self.OnVolumeIsosurfMap)
Definition: tools.py:2334
void write_image(void)
int
Definition: g3dcolor.c:48
int mapped
int height