[Gridflow-cvs] [svn] commit: r3683 - in /trunk: base/grid.c gridflow.c gridflow.h

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Apr 28 12:55:50 EDT 2008


Author: matju
Date: Mon Apr 28 12:55:50 2008
New Revision: 3683

Log:
fix leak in exception-handling (don't use operator new)

Modified:
    trunk/base/grid.c
    trunk/gridflow.c
    trunk/gridflow.h

Modified: trunk/base/grid.c
==============================================================================
--- trunk/base/grid.c (original)
+++ trunk/base/grid.c Mon Apr 28 12:55:50 2008
@@ -158,12 +158,12 @@
 	P<Dim> dim = this->dim = back_out->dim;
 	dex=0;
 	buf=0;
-	try {GridInlet_begin_1(this);} catch (Barf *barf) {GridInlet_begin_2(this); throw;}
+	try {GridInlet_begin_1(this);} catch (Barf &barf) {GridInlet_begin_2(this); throw;}
 	this->dim = dim;
 	back_out->callback(this);
 }
 
-#define CATCH_IT catch (Barf *slimy) {post("error during flow: %s",slimy->text);}
+#define CATCH_IT catch (Barf &slimy) {post("error during flow: %s",slimy->text);}
 
 template <class T> void GridInlet::flow(int mode, long n, T *data) {TRACE;
 	CHECK_BUSY(inlet);

Modified: trunk/gridflow.c
==============================================================================
--- trunk/gridflow.c (original)
+++ trunk/gridflow.c Mon Apr 28 12:55:50 2008
@@ -535,7 +535,7 @@
 	m = funcall_lookup(bself,"anything");
 	if (m) {SETSYMBOL(argv+0,gensym(buf)); m(bself->self,argc+1,argv); return;}
 	pd_error((t_pd *)bself, "method '%s' not found for inlet %d in class '%s'",selector->s_name,winlet,pd_classname(bself));
-    } catch (Barf *oozy) {pd_error(bself,"%s",oozy->text);}
+    } catch (Barf &oozy) {pd_error(bself,"%s",oozy->text);}
 }
 static void BFObject_anything0 (BFObject *self, t_symbol *s, int argc, t_atom2 *argv) {
 	BFObject_anything(self,0,s,argc,argv);
@@ -590,11 +590,11 @@
 		if (argv[k].a_type==A_SYMBOL) pd_typedmess((t_pd *)bself,argv[k].a_w.w_symbol,j-k-1,argv+k+1);
 	}
 	return bself;
-    } catch (Barf *oozy) {pd_error(bself,"%s",oozy->text); return 0;}
+    } catch (Barf &oozy) {pd_error(bself,"%s",oozy->text); return 0;}
 }
 
 static void BFObject_delete (BFObject *bself) {
-	try {delete bself->self;} catch (Barf *oozy) {pd_error(bself,"%s",oozy->text);}
+	try {delete bself->self;} catch (Barf &oozy) {pd_error(bself,"%s",oozy->text);}
 	bself->ninlets_set(1,false);
 	delete[] bself->inlets;
 	delete[] bself->outlets;
@@ -839,5 +839,5 @@
 	signal(SIGABRT,SIG_DFL);
 	signal(SIGBUS, SIG_DFL);
 	atexit(gridflow_unsetup);
-    } catch (Barf *oozy) {post("Init_gridflow error: %s",oozy->text);}
-}
+    } catch (Barf &oozy) {post("Init_gridflow error: %s",oozy->text);}
+}

Modified: trunk/gridflow.h
==============================================================================
--- trunk/gridflow.h (original)
+++ trunk/gridflow.h Mon Apr 28 12:55:50 2008
@@ -195,7 +195,7 @@
 
 //#define _L_ post("%s:%d in %s",__FILE__,__LINE__,__PRETTY_FUNCTION__);
 #define _L_ fprintf(stderr,"%s:%d in %s\n",__FILE__,__LINE__,__PRETTY_FUNCTION__);
-#define RAISE(args...) throw new Barf(__FILE__,__LINE__,__PRETTY_FUNCTION__,args)
+#define RAISE(args...) throw Barf(__FILE__,__LINE__,__PRETTY_FUNCTION__,args)
 #define VA int argc, t_atom2 *argv
 // returns the size of a statically defined array
 #define COUNT(_array_) ((int)(sizeof(_array_) / sizeof((_array_)[0])))



More information about the Gridflow-cvs mailing list