[GRASS-SVN] r58336 - grass/trunk/vector/v.clean
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Nov 30 00:33:06 PST 2013
Author: martinl
Date: 2013-11-30 00:33:06 -0800 (Sat, 30 Nov 2013)
New Revision: 58336
Modified:
grass/trunk/vector/v.clean/main.c
Log:
v.clean: use error handlers to clean up when fails
Modified: grass/trunk/vector/v.clean/main.c
===================================================================
--- grass/trunk/vector/v.clean/main.c 2013-11-29 19:53:29 UTC (rev 58335)
+++ grass/trunk/vector/v.clean/main.c 2013-11-30 08:33:06 UTC (rev 58336)
@@ -25,6 +25,8 @@
#include "proto.h"
+static void error_handler_err(void *p);
+
int main(int argc, char *argv[])
{
struct Map_info In, Out, Err, *pErr;
@@ -276,18 +278,13 @@
with_z = Vect_is_3d(&In);
- if (0 > Vect_open_new(&Out, opt.out->answer, with_z)) {
- Vect_close(&In);
- exit(EXIT_FAILURE);
- }
+ Vect_open_new(&Out, opt.out->answer, with_z);
+ Vect_set_error_handler_io(&In, &Out);
if (opt.err->answer) {
Vect_set_open_level(2);
- if (0 > Vect_open_new(&Err, opt.err->answer, with_z)) {
- Vect_close(&In);
- Vect_close(&Out);
- exit(EXIT_FAILURE);
- }
+ Vect_open_new(&Err, opt.err->answer, with_z);
+ G_add_error_handler(error_handler_err, &Err);
pErr = &Err;
}
else {
@@ -493,3 +490,17 @@
exit(EXIT_SUCCESS);
}
+
+void error_handler_err(void *p)
+{
+ char *name;
+ struct Map_info *Err;
+
+ Err = (struct Map_info *) p;
+
+ if (Err && Err->open == VECT_OPEN_CODE) {
+ name = G_store(Err->name);
+ Vect_delete(name);
+ G_free(name);
+ }
+}
More information about the grass-commit
mailing list