@@ -72,6 +72,7 @@ int load_vectors(const struct Option *elev_map, const struct Option *elev_const,
72
72
73
73
surf_list = GS_get_surf_list (& nsurf );
74
74
GS_set_att_const (surf_list [0 ], ATT_TRANSP , 255 );
75
+ G_free (surf_list );
75
76
}
76
77
77
78
nvects = 0 ;
@@ -81,9 +82,9 @@ int load_vectors(const struct Option *elev_map, const struct Option *elev_const,
81
82
if (mapset == NULL ) {
82
83
G_fatal_error (_ ("Vector map <%s> not found" ), vect -> answers [i ]);
83
84
}
84
- id = Nviz_new_map_obj ( map_obj_type ,
85
- G_fully_qualified_name ( vect -> answers [ i ], mapset ),
86
- 0.0 , data );
85
+ char * mname = G_fully_qualified_name ( vect -> answers [ i ], mapset );
86
+ id = Nviz_new_map_obj ( map_obj_type , mname , 0.0 , data );
87
+ G_free ( mname );
87
88
88
89
/* set position */
89
90
x = atof (position -> answers [i * 3 + 0 ]);
@@ -111,7 +112,7 @@ int load_vectors(const struct Option *elev_map, const struct Option *elev_const,
111
112
*/
112
113
int vlines_set_attrb (const struct GParams * params )
113
114
{
114
- int i , layer , color , width , flat , height ;
115
+ int i , layer = -1 , color , width , flat , height ;
115
116
int * vect_list , nvects ;
116
117
int have_colors ;
117
118
@@ -138,23 +139,28 @@ int vlines_set_attrb(const struct GParams *params)
138
139
flat = 0 ;
139
140
140
141
/* style (mode -- use memory by default) */
141
- if (GV_set_style (vect_list [i ], TRUE, color , width , flat ) < 0 )
142
+ if (GV_set_style (vect_list [i ], TRUE, color , width , flat ) < 0 ) {
143
+ G_free (vect_list );
142
144
return 0 ;
145
+ }
143
146
144
147
/* check for vector color table */
145
148
have_colors = Vect_read_colors (params -> vlines -> answers [i ], "" , & colors );
146
149
147
150
if (have_colors || color_column || width_column )
148
151
if (GV_set_style_thematic (vect_list [i ], layer , color_column ,
149
152
width_column ,
150
- have_colors ? & colors : NULL ) < 0 )
153
+ have_colors ? & colors : NULL ) < 0 ) {
154
+ G_free (vect_list );
151
155
return 0 ;
156
+ }
152
157
153
158
/* height */
154
159
height = atoi (params -> vline_height -> answers [i ]);
155
160
if (height > 0 )
156
161
GV_set_trans (vect_list [i ], 0.0 , 0.0 , height );
157
162
}
163
+ G_free (vect_list );
158
164
159
165
return 1 ;
160
166
}
@@ -169,7 +175,7 @@ int vlines_set_attrb(const struct GParams *params)
169
175
*/
170
176
int vpoints_set_attrb (const struct GParams * params )
171
177
{
172
- int i , layer , have_colors , with_z ;
178
+ int i , have_colors ;
173
179
int * site_list , nsites ;
174
180
int marker , color , width ;
175
181
float size ;
@@ -181,6 +187,7 @@ int vpoints_set_attrb(const struct GParams *params)
181
187
site_list = GP_get_site_list (& nsites );
182
188
183
189
for (i = 0 ; i < nsites ; i ++ ) {
190
+ int layer = -1 , with_z = 0 ;
184
191
check_map (params , i , FALSE, & layer , & with_z );
185
192
186
193
color = Nviz_color_from_str (params -> vpoint_color -> answers [i ]);
@@ -208,8 +215,10 @@ int vpoints_set_attrb(const struct GParams *params)
208
215
GP_set_zmode (site_list [i ], TRUE);
209
216
}
210
217
211
- if (GP_set_style (site_list [i ], color , width , size , marker ) < 0 )
218
+ if (GP_set_style (site_list [i ], color , width , size , marker ) < 0 ) {
219
+ G_free (site_list );
212
220
return 0 ;
221
+ }
213
222
214
223
/* check for vector color table */
215
224
have_colors =
@@ -219,10 +228,13 @@ int vpoints_set_attrb(const struct GParams *params)
219
228
marker_column ) {
220
229
if (GP_set_style_thematic (site_list [i ], layer , color_column ,
221
230
width_column , size_column , marker_column ,
222
- have_colors ? & colors : NULL ) < 0 )
231
+ have_colors ? & colors : NULL ) < 0 ) {
232
+ G_free (site_list );
223
233
return 0 ;
234
+ }
224
235
}
225
236
}
237
+ G_free (site_list );
226
238
227
239
return 1 ;
228
240
}
@@ -251,6 +263,7 @@ int check_map(const struct GParams *params, int index, int vlines, int *field,
251
263
252
264
Fi = NULL ;
253
265
driver = NULL ;
266
+ column = NULL ;
254
267
255
268
if (vlines ) {
256
269
map = params -> vlines -> answers [index ];
@@ -310,6 +323,8 @@ int check_map(const struct GParams *params, int index, int vlines, int *field,
310
323
311
324
if (db_column_Ctype (driver , Fi -> table , color ) != DB_C_TYPE_STRING )
312
325
G_fatal_error (_ ("Data type of color column must be character" ));
326
+ db_free_column (column );
327
+ column = NULL ;
313
328
}
314
329
if (size ) {
315
330
db_get_column (driver , Fi -> table , size , & column );
@@ -320,6 +335,8 @@ int check_map(const struct GParams *params, int index, int vlines, int *field,
320
335
type = db_column_Ctype (driver , Fi -> table , size );
321
336
if (type != DB_C_TYPE_INT && type != DB_C_TYPE_DOUBLE )
322
337
G_fatal_error (_ ("Data type of size column must be numeric" ));
338
+ db_free_column (column );
339
+ column = NULL ;
323
340
}
324
341
if (width ) {
325
342
db_get_column (driver , Fi -> table , width , & column );
@@ -330,6 +347,8 @@ int check_map(const struct GParams *params, int index, int vlines, int *field,
330
347
type = db_column_Ctype (driver , Fi -> table , width );
331
348
if (type != DB_C_TYPE_INT && type != DB_C_TYPE_DOUBLE )
332
349
G_fatal_error (_ ("Data type of width column must be numeric" ));
350
+ db_free_column (column );
351
+ column = NULL ;
333
352
}
334
353
if (marker ) {
335
354
db_get_column (driver , Fi -> table , marker , & column );
@@ -341,9 +360,12 @@ int check_map(const struct GParams *params, int index, int vlines, int *field,
341
360
if (db_column_Ctype (driver , Fi -> table , marker ) != DB_C_TYPE_STRING )
342
361
G_fatal_error (
343
362
_ ("Data type of marker column must be character" ));
363
+ db_free_column (column );
364
+ column = NULL ;
344
365
}
345
366
346
367
db_close_database_shutdown_driver (driver );
368
+ Vect_destroy_field_info (Fi );
347
369
}
348
370
349
371
Vect_close (& Map );
0 commit comments