[Xastir-dev] Re: [Xastir-checkins] CVS: xastir/src map_shp.c, 1.52, 1.53 dbfawk.c, 1.10, 1.11

Alan Crosswell alan at columbia.edu
Mon May 24 17:59:13 EDT 2004


Curt,

Make sure these frees aren't freeing stuff that's supposed to hang around 
between invocations.  I specifically set things up to have dbfawk only parse a 
.dbfawk file once and then keep the data structures around so that subsequent 
displays of a matching map won't have to go through all that initialization each 
time....
/a


Curt Mills wrote:
> Update of /cvsroot/xastir/xastir/src
> In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30267
> 
> Modified Files:
> 	map_shp.c dbfawk.c 
> Log Message:
> Adding some free() statements to exit points in map_shp.c, to de-allocate
> memory that was allocated earlier in the function via dbfawk calls.
> 
> 
> Index: map_shp.c
> ===================================================================
> RCS file: /cvsroot/xastir/xastir/src/map_shp.c,v
> retrieving revision 1.52
> retrieving revision 1.53
> diff -C2 -d -r1.52 -r1.53
> *** map_shp.c	24 May 2004 00:01:44 -0000	1.52
> --- map_shp.c	24 May 2004 21:53:26 -0000	1.53
> ***************
> *** 812,815 ****
> --- 812,816 ----
>               /* find out which dbf fields we care to read */
>               fld_info = dbfawk_field_list(hDBF, dbffields);
> + 
>           } else {                /* should never be reached anymore! */
>               fprintf(stderr,"No DBFAWK signature for %s and no default!\n",filenm);
> ***************
> *** 1253,1256 ****
> --- 1254,1261 ----
>           DBFClose( hDBF );   // Clean up open file descriptors
>   
> + #ifdef WITH_DBFAWK
> +         dbfawk_free_info(fld_info);
> + #endif
> + 
>           return;
>       }
> ***************
> *** 1277,1280 ****
> --- 1282,1289 ----
>           SHPClose( hSHP );
>   
> + #ifdef WITH_DBFAWK
> +         dbfawk_free_info(fld_info);
> + #endif
> + 
>           return; // Done indexing this file
>       }
> ***************
> *** 1304,1307 ****
> --- 1313,1320 ----
>               SHPClose( hSHP );
>   
> + #ifdef WITH_DBFAWK
> +         dbfawk_free_info(fld_info);
> + #endif
> + 
>               return; // Multipoint type.  Not implemented yet.
>               break;
> ***************
> *** 1311,1314 ****
> --- 1324,1331 ----
>               SHPClose( hSHP );
>   
> + #ifdef WITH_DBFAWK
> +         dbfawk_free_info(fld_info);
> + #endif
> + 
>               return; // Unknown type.  Don't know how to process it.
>               break;
> ***************
> *** 1339,1342 ****
> --- 1356,1363 ----
>           SHPClose( hSHP );
>   
> + #ifdef WITH_DBFAWK
> +         dbfawk_free_info(fld_info);
> + #endif
> + 
>           return;     // The file contains no shapes in our viewport
>       }
> ***************
> *** 1465,1468 ****
> --- 1486,1494 ----
>           // Update to screen
>           (void)XCopyArea(XtDisplay(da),pixmap,XtWindow(da),gc,0,0,screen_width,screen_height,0,0);
> + 
> + #ifdef WITH_DBFAWK
> +         dbfawk_free_info(fld_info);
> + #endif
> + 
>           return;
>       }
> ***************
> *** 3344,3348 ****
>                       // the "hole" flags for the shape.
>                       free(polygon_hole_storage);
> - 
>                       if (polygon_hole_flag) {
>                           //Free the temporary GC that we may have used to
> --- 3370,3373 ----
> 
> Index: dbfawk.c
> ===================================================================
> RCS file: /cvsroot/xastir/xastir/src/dbfawk.c,v
> retrieving revision 1.10
> retrieving revision 1.11
> diff -C2 -d -r1.10 -r1.11
> *** dbfawk.c	24 May 2004 00:01:33 -0000	1.10
> --- dbfawk.c	24 May 2004 21:53:27 -0000	1.11
> ***************
> *** 78,82 ****
>   /*
>    * dbfawk_field_list: Generate a list of info about fields to read for
> !  *  a given a DBFHandle and colon-separated list of fieldnames.
>    */
>   dbfawk_field_info *dbfawk_field_list(DBFHandle dbf, char *dbffields)
> --- 78,82 ----
>   /*
>    * dbfawk_field_list: Generate a list of info about fields to read for
> !  *  a given DBFHandle and colon-separated list of fieldnames.
>    */
>   dbfawk_field_info *dbfawk_field_list(DBFHandle dbf, char *dbffields)
> ***************
> *** 91,96 ****
>       char junk[XBASE_FLDHDR_SZ];
>       int w,prec;
> !     
>       fi = calloc(1,sizeof(dbfawk_field_info));
>       if (!fi)
>           return NULL;
> --- 91,97 ----
>       char junk[XBASE_FLDHDR_SZ];
>       int w,prec;
> ! 
>       fi = calloc(1,sizeof(dbfawk_field_info));
> +  
>       if (!fi)
>           return NULL;
> ***************
> *** 145,149 ****
>           int len = strlen(e->d_name);
>           char *path = calloc(1,len+strlen(dir)+2);
> ! 
>           if (!path) {
>               fprintf(stderr,"failed to malloc in dbfawk.c!\n");
> --- 146,150 ----
>           int len = strlen(e->d_name);
>           char *path = calloc(1,len+strlen(dir)+2);
> !  
>           if (!path) {
>               fprintf(stderr,"failed to malloc in dbfawk.c!\n");
> ***************
> *** 183,188 ****
>           if (sig->prog)
>               awk_free_program(sig->prog);
> !         if (sig)
>               free(sig);
>       }
>   }
> --- 184,190 ----
>           if (sig->prog)
>               awk_free_program(sig->prog);
> !         if (sig) {
>               free(sig);
> +         }
>       }
>   }
> ***************
> *** 225,228 ****
> --- 227,231 ----
>           strcat(perfile,".dbfawk");
>           info = calloc(1,sizeof(*info));
> +  
>           if (!info) {
>               fprintf(stderr,"failed to malloc in dbfawk_find_sig!\n");
> ***************
> *** 235,242 ****
>           info->sig = NULL;
>           free(perfile);
> !         if (info->prog)
>               return info;
> !         else
>               free(info);
>           /* fall through and do normal signature search */
>       }
> --- 238,247 ----
>           info->sig = NULL;
>           free(perfile);
> !         if (info->prog) {
>               return info;
> !         }
> !         else {
>               free(info);
> +         }
>           /* fall through and do normal signature search */
>       }
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... Oracle 10g. 
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> _______________________________________________
> Xastir-checkins mailing list
> Xastir-checkins at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xastir-checkins



More information about the Xastir-dev mailing list