@@ -3244,13 +3244,13 @@ PSDeviceDriver(pDevDesc dd, const char *file, const char *paper,
32443244 /* Check and extract the device parameters */
32453245
32463246 if (strlen (file ) > R_PATH_MAX - 1 ) {
3247- free (dd );
3247+ GEfreeDD (dd );
32483248 error (_ ("filename too long in %s()" ), "postscript" );
32493249 }
32503250
32513251 /* allocate new postscript device description */
32523252 if (!(pd = (PostScriptDesc * ) malloc (sizeof (PostScriptDesc )))) {
3253- free (dd );
3253+ GEfreeDD (dd );
32543254 error (_ ("memory allocation problem in %s()" ), "postscript" );
32553255 }
32563256
@@ -3714,7 +3714,7 @@ static void PS_cleanup(int stage, pDevDesc dd, PostScriptDesc *pd)
37143714 freeDeviceEncList (pd -> encodings );
37153715 case 1 : /* Allocated PDFDesc */
37163716 free (pd );
3717- free (dd );
3717+ GEfreeDD (dd );
37183718 }
37193719}
37203720
@@ -6854,7 +6854,7 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
68546854 bool timestamp , bool producer , const char * author )
68556855{
68566856 /* If we need to bail out with some sort of "error" */
6857- /* then we must free (dd) */
6857+ /* then we must GEfreeDD (dd) */
68586858
68596859 int i , gotFont ;
68606860 double xoff = 0.0 , yoff = 0.0 , pointsize ;
@@ -6871,13 +6871,13 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
68716871 /* 'file' could be NULL */
68726872 if (file && strlen (file ) > R_PATH_MAX - 1 ) {
68736873 /* not yet created PDFcleanup(0, pd); */
6874- free (dd );
6874+ GEfreeDD (dd );
68756875 error (_ ("filename too long in %s()" ), "pdf" );
68766876 }
68776877
68786878 /* allocate new PDF device description */
68796879 if (!(pd = (PDFDesc * ) malloc (sizeof (PDFDesc )))) {
6880- free (dd );
6880+ GEfreeDD (dd );
68816881 error (_ ("memory allocation problem in %s()" ), "pdf" );
68826882 }
68836883 /* from here on, if need to bail out with "error", must also
@@ -6897,15 +6897,15 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
68976897 pd -> pos = (int * ) calloc (pd -> max_nobjs , sizeof (int ));
68986898 if (!pd -> pos ) {
68996899 PDFcleanup (1 , pd );
6900- free (dd );
6900+ GEfreeDD (dd );
69016901 error ("cannot allocate pd->pos" );
69026902 }
69036903 /* This one is dynamic: initial allocation */
69046904 pd -> pagemax = 100 ;
69056905 pd -> pageobj = (int * ) calloc (pd -> pagemax , sizeof (int ));
69066906 if (!pd -> pageobj ) {
69076907 PDFcleanup (2 , pd );
6908- free (dd );
6908+ GEfreeDD (dd );
69096909 error ("cannot allocate pd->pageobj" );
69106910 }
69116911
@@ -6944,7 +6944,7 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
69446944
69456945 if (strlen (encoding ) > R_PATH_MAX - 1 ) {
69466946 PDFcleanup (3 , pd );
6947- free (dd );
6947+ GEfreeDD (dd );
69486948 error (_ ("encoding path is too long in %s()" ), "pdf" );
69496949 }
69506950 /*
@@ -6960,7 +6960,7 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
69606960 pd -> encodings = enclist ;
69616961 } else {
69626962 PDFcleanup (3 , pd );
6963- free (dd );
6963+ GEfreeDD (dd );
69646964 error (_ ("failed to load default encoding" ));
69656965 }
69666966
@@ -7027,7 +7027,7 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
70277027 }
70287028 if (!gotFont ) {
70297029 PDFcleanup (4 , pd );
7030- free (dd );
7030+ GEfreeDD (dd );
70317031 error (_ ("failed to initialise default PDF font" ));
70327032 }
70337033
@@ -7082,7 +7082,7 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
70827082 }
70837083 if (gotFonts < nfonts ) {
70847084 PDFcleanup (4 , pd );
7085- free (dd );
7085+ GEfreeDD (dd );
70867086 error (_ ("failed to initialise additional PDF fonts" ));
70877087 }
70887088 }
@@ -7095,14 +7095,14 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
70957095 pd -> rasters = initRasterArray (pd -> maxRasters );
70967096 if (!pd -> rasters ) {
70977097 PDFcleanup (4 , pd );
7098- free (dd );
7098+ GEfreeDD (dd );
70997099 error (_ ("failed to allocate rasters" ));
71007100 }
71017101 pd -> numMasks = 0 ;
71027102 pd -> masks = initMaskArray (pd -> maxRasters );
71037103 if (!pd -> masks ) {
71047104 PDFcleanup (5 , pd );
7105- free (dd );
7105+ GEfreeDD (dd );
71067106 error (_ ("failed to allocate masks" ));
71077107 }
71087108
@@ -7112,7 +7112,7 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
71127112 initDefinitions (pd );
71137113 if (!pd -> definitions ) {
71147114 PDFcleanup (6 , pd );
7115- free (dd );
7115+ GEfreeDD (dd );
71167116 error (_ ("failed to allocate definitions" ));
71177117 }
71187118 pd -> appendingPath = -1 ;
@@ -7185,7 +7185,7 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
71857185 char errbuf [strlen (pd -> papername ) + 1 ];
71867186 strcpy (errbuf , pd -> papername );
71877187 PDFcleanup (7 , pd );
7188- free (dd );
7188+ GEfreeDD (dd );
71897189 error (_ ("invalid paper type '%s' (pdf)" ), errbuf );
71907190 }
71917191 pd -> pagecentre = pagecentre ;
@@ -7209,7 +7209,7 @@ PDFDeviceDriver(pDevDesc dd, const char *file, const char *paper,
72097209 pointsize = floor (ps );
72107210 if (R_TRANSPARENT (setbg ) && R_TRANSPARENT (setfg )) {
72117211 PDFcleanup (7 , pd );
7212- free (dd );
7212+ GEfreeDD (dd );
72137213 error (_ ("invalid foreground/background color (pdf)" ));
72147214 }
72157215
@@ -8210,7 +8210,7 @@ static void PDF_Open(pDevDesc dd, PDFDesc *pd)
82108210 pd -> mainfp = R_fopen (R_ExpandFileName (buf ), "wb" );
82118211 if (!pd -> mainfp ) {
82128212 PDFcleanup (7 , pd );
8213- free (dd );
8213+ GEfreeDD (dd );
82148214 error (_ ("cannot open file '%s'" ), buf );
82158215 }
82168216 pd -> pdffp = pd -> mainfp ;
@@ -9976,7 +9976,7 @@ SEXP PostScript(SEXP args)
99769976 R_CheckDeviceAvailable ();
99779977 BEGIN_SUSPEND_INTERRUPTS {
99789978 pDevDesc dev ;
9979- if (!(dev = ( pDevDesc ) calloc ( 1 , sizeof ( DevDesc ) )))
9979+ if (!(dev = GEcreateDD ( )))
99809980 return 0 ;
99819981 if (!PSDeviceDriver (dev , file , paper , family , afms , encoding , bg , fg ,
99829982 width , height , (bool )horizontal , ps , onefile ,
@@ -10086,7 +10086,7 @@ SEXP PDF(SEXP args)
1008610086 R_CheckDeviceAvailable ();
1008710087 BEGIN_SUSPEND_INTERRUPTS {
1008810088 pDevDesc dev ;
10089- if (!(dev = ( pDevDesc ) calloc ( 1 , sizeof ( DevDesc ) )))
10089+ if (!(dev = GEcreateDD ( )))
1009010090 return 0 ;
1009110091 if (!PDFDeviceDriver (dev , file , paper , family , afms , encoding , bg , fg ,
1009210092 width , height , ps , onefile , pagecentre ,
0 commit comments