Changeset: 701842f605f2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=701842f605f2
Modified Files:
geom/monetdb5/geomBulk.c
Branch: Jun2016
Log Message:
Sanitize exception handling.
diffs (truncated from 583 to 300 lines):
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -49,12 +49,9 @@ str geom_2_geom_bat(bat* outBAT_id, bat*
//if for used --> inWKB = (wkb *) BUNtail(inBATi, i +
BUNfirst(inBAT));
inWKB = (wkb*) BUNtail(inBAT_iter, p);
if ((err = geom_2_geom(&outWKB, &inWKB, columnType,
columnSRID)) != MAL_SUCCEED) { //check type
- str msg;
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
- msg = createException(MAL, "batcalc.wkb", "%s", err);
- GDKfree(err);
- return msg;
+ return err;
}
BUNappend(outBAT,outWKB,TRUE); //add the point to the new BAT
GDKfree(outWKB);
@@ -104,13 +101,9 @@ str wkbFromText_bat(bat *outBAT_id, bat
inWKB = (char*) BUNtail(inBAT_iter, p);
if ((err = wkbFromText(&outSingle, &inWKB, srid, tpe)) !=
MAL_SUCCEED) {
- str msg = createException(MAL, "batgeom.wkbFromText",
"%s", err);
- GDKfree(err);
-
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
-
- return msg;
+ return err;
}
BUNappend(outBAT,outSingle,TRUE); //add the result to the new
BAT
GDKfree(outSingle);
@@ -161,12 +154,9 @@ str wkbCoordinateFromMBR_bat(bat *outBAT
inMBR = (mbr*) BUNtail(inBAT_iter, p);
if ((err = wkbCoordinateFromMBR(&outDbl, &inMBR,
coordinateIdx)) != MAL_SUCCEED) {
- str msg;
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
- msg = createException(MAL, "batgeom.coordinateFromMBR",
"%s", err);
- GDKfree(err);
- return msg;
+ return err;
}
BUNappend(outBAT,&outDbl,TRUE);
}
@@ -216,13 +206,9 @@ static str WKBtoSTRflagINT_bat(bat *outB
inWKB = (wkb*) BUNtail(inBAT_iter, p);
if ((err = (*func)(&outSingle, &inWKB, flag)) != MAL_SUCCEED) {
- str msg = createException(MAL, name, "%s", err);
- GDKfree(err);
-
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
-
- return msg;
+ return err;
}
BUNappend(outBAT,outSingle,TRUE); //add the result to the new
BAT
GDKfree(outSingle);
@@ -282,13 +268,9 @@ static str WKBtoWKB_bat(bat *outBAT_id,
inWKB = (wkb*) BUNtail(inBAT_iter, p);
if ((err = (*func)(&outSingle, &inWKB)) != MAL_SUCCEED) {
- str msg = createException(MAL, name, "%s", err);
- GDKfree(err);
-
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
-
- return msg;
+ return err;
}
BUNappend(outBAT,outSingle,TRUE); //add the result to the new
BAT
GDKfree(outSingle);
@@ -345,13 +327,9 @@ static str WKBtoWKBflagINT_bat(bat *outB
inWKB = (wkb*) BUNtail(inBAT_iter, p);
if ((err = (*func)(&outSingle, &inWKB, flag)) != MAL_SUCCEED) {
- str msg = createException(MAL, name, "%s", err);
- GDKfree(err);
-
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
-
- return msg;
+ return err;
}
BUNappend(outBAT,outSingle,TRUE); //add the result to the new
BAT
GDKfree(outSingle);
@@ -407,13 +385,9 @@ static str WKBtoBIT_bat(bat *outBAT_id,
inWKB = (wkb*) BUNtail(inBAT_iter, p);
if ((err = (*func)(&outSingle, &inWKB)) != MAL_SUCCEED) {
- str msg = createException(MAL, name, "%s", err);
- GDKfree(err);
-
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
-
- return msg;
+ return err;
}
BUNappend(outBAT,&outSingle,TRUE); //add the result to the new
BAT
}
@@ -481,13 +455,9 @@ static str WKBtoINT_bat(bat *outBAT_id,
inWKB = (wkb*) BUNtail(inBAT_iter, p);
if ((err = (*func)(&outSingle, &inWKB)) != MAL_SUCCEED) {
- str msg = createException(MAL, name, "%s", err);
- GDKfree(err);
-
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
-
- return msg;
+ return err;
}
BUNappend(outBAT,&outSingle,TRUE); //add the result to the new
BAT
}
@@ -545,13 +515,9 @@ static str WKBtoINTflagINT_bat(bat *outB
inWKB = (wkb*) BUNtail(inBAT_iter, p);
if ((err = (*func)(&outSingle, &inWKB, flag)) != MAL_SUCCEED) {
- str msg = createException(MAL, name, "%s", err);
- GDKfree(err);
-
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
-
- return msg;
+ return err;
}
BUNappend(outBAT,&outSingle,TRUE); //add the result to the new
BAT
}
@@ -609,13 +575,9 @@ str wkbGetCoordinate_bat(bat *outBAT_id,
inWKB = (wkb*) BUNtail(inBAT_iter, p);
if ((err = wkbGetCoordinate(&outSingle, &inWKB, flag)) !=
MAL_SUCCEED) {
- str msg = createException(MAL,
"batgeom.wkbGetCoordinate", "%s", err);
- GDKfree(err);
-
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
-
- return msg;
+ return err;
}
BUNappend(outBAT,&outSingle,TRUE); //add the result to the new
BAT
}
@@ -670,18 +632,13 @@ str wkbBox2D_bat(bat* outBAT_id, bat *aB
bBAT_iter = bat_iterator(bBAT);
for (i = BUNfirst(aBAT); i < BATcount(aBAT); i++) {
- str err = NULL;
mbr *outSingle;
wkb *aWKB = (wkb*) BUNtail(aBAT_iter, i + BUNfirst(aBAT));
wkb *bWKB = (wkb*) BUNtail(bBAT_iter, i + BUNfirst(bBAT));
- if ((err = wkbBox2D(&outSingle, &aWKB, &bWKB)) != MAL_SUCCEED) {
+ if ((ret = wkbBox2D(&outSingle, &aWKB, &bWKB)) != MAL_SUCCEED) {
BBPunfix(outBAT->batCacheid);
-
- ret = createException(MAL, "batgeom.wkbBox2D", "%s",
err);
- GDKfree(err);
-
goto clean;
}
BUNappend(outBAT,outSingle,TRUE); //add the result to the outBAT
@@ -736,18 +693,13 @@ str wkbContains_bat(bat* outBAT_id, bat
bBAT_iter = bat_iterator(bBAT);
for (i = BUNfirst(aBAT); i < BATcount(aBAT); i++) {
- str err = NULL;
bit outBIT;
wkb *aWKB = (wkb*) BUNtail(aBAT_iter, i + BUNfirst(aBAT));
wkb *bWKB = (wkb*) BUNtail(bBAT_iter, i + BUNfirst(bBAT));
- if ((err = wkbContains(&outBIT, &aWKB, &bWKB)) != MAL_SUCCEED) {
- BBPunfix(outBAT->batCacheid);
-
- ret = createException(MAL, "batgeom.Contains", "%s",
err);
- GDKfree(err);
-
+ if ((ret = wkbContains(&outBIT, &aWKB, &bWKB)) != MAL_SUCCEED) {
+ BBPunfix(outBAT->batCacheid);
goto clean;
}
BUNappend(outBAT,&outBIT,TRUE); //add the result to the outBAT
@@ -771,18 +723,18 @@ str wkbContains_geom_bat(bat* outBAT_id,
//get the descriptor of the BAT
if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
- return createException(MAL, "batgeom.Contains", "Problem
retrieving BAT");
+ throw(MAL, "batgeom.Contains", "Problem retrieving BAT");
}
if ( !BAThdense(inBAT) ) {
BBPunfix(inBAT->batCacheid);
- return createException(MAL, "batgeom.Contains", "The BAT must
have dense head");
+ throw(MAL, "batgeom.Contains", "The BAT must have dense head");
}
//create a new BAT for the output
if ((outBAT = BATnew(TYPE_void, ATOMindex("bit"), BATcount(inBAT),
TRANSIENT)) == NULL) {
BBPunfix(inBAT->batCacheid);
- return createException(MAL, "batgeom.Contains", "Error creating
new BAT");
+ throw(MAL, "batgeom.Contains", "Error creating new BAT");
}
//set the first idx of the output BAT equal to that of the aBAT
@@ -797,12 +749,9 @@ str wkbContains_geom_bat(bat* outBAT_id,
wkb *inWKB = (wkb*) BUNtail(inBAT_iter, p);
if ((err = wkbContains(&outBIT, geomWKB, &inWKB)) !=
MAL_SUCCEED) {
- str msg;
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
- msg = createException(MAL, "batgeom.Contains", "%s",
err);
- GDKfree(err);
- return msg;
+ return err;
}
BUNappend(outBAT,&outBIT,TRUE); //add the result to the outBAT
}
@@ -821,18 +770,18 @@ str wkbContains_bat_geom(bat* outBAT_id,
//get the descriptor of the BAT
if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
- return createException(MAL, "batgeom.Contains", "Problem
retrieving BAT");
+ throw(MAL, "batgeom.Contains", "Problem retrieving BAT");
}
if ( !BAThdense(inBAT) ) {
BBPunfix(inBAT->batCacheid);
- return createException(MAL, "batgeom.Contains", "The BAT must
have dense head");
+ throw(MAL, "batgeom.Contains", "The BAT must have dense head");
}
//create a new BAT for the output
if ((outBAT = BATnew(TYPE_void, ATOMindex("bit"), BATcount(inBAT),
TRANSIENT)) == NULL) {
BBPunfix(inBAT->batCacheid);
- return createException(MAL, "batgeom.Contains", "Error creating
new BAT");
+ throw(MAL, "batgeom.Contains", "Error creating new BAT");
}
//set the first idx of the output BAT equal to that of the aBAT
@@ -847,12 +796,9 @@ str wkbContains_bat_geom(bat* outBAT_id,
wkb *inWKB = (wkb*) BUNtail(inBAT_iter, p);
if ((err = wkbContains(&outBIT, &inWKB, geomWKB)) !=
MAL_SUCCEED) {
- str msg;
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
- msg = createException(MAL, "batgeom.Contains", "%s",
err);
- GDKfree(err);
- return msg;
+ return err;
}
BUNappend(outBAT,&outBIT,TRUE); //add the result to the outBAT
}
@@ -894,12 +840,9 @@ str wkbFromWKB_bat(bat* outBAT_id, bat*
for (i = 0; i < BATcount(inBAT); i++) { //iterate over all valid
elements
str err = NULL;
if ((err = wkbFromWKB(&outWKB, &inWKB[i])) != MAL_SUCCEED) {
- str msg;
BBPunfix(inBAT->batCacheid);
BBPunfix(outBAT->batCacheid);
- msg = createException(MAL, "batgeom.wkb", "%s", err);
- GDKfree(err);
- return msg;
+ return err;
}
BUNappend(outBAT,outWKB,TRUE); //add the point to the new BAT
GDKfree(outWKB);
@@ -968,7 +911,6 @@ str wkbMakePoint_bat(bat* outBAT_id, bat
mBAT_iter = bat_iterator(mBAT);
for (i = BUNfirst(xBAT); i < BATcount(xBAT); i++) {
- str err = NULL;
wkb *pointWKB = NULL;
double x = *((double*) BUNtail(xBAT_iter, i + BUNfirst(xBAT)));
@@ -981,12 +923,9 @@ str wkbMakePoint_bat(bat* outBAT_id, bat
if(mBAT)
m = *((double*) BUNtail(mBAT_iter, i + BUNfirst(mBAT)));
- if ((err = wkbMakePoint(&pointWKB, &x, &y, &z, &m, zmFlag)) !=
MAL_SUCCEED) { //check
+ if ((ret = wkbMakePoint(&pointWKB, &x, &y, &z, &m, zmFlag)) !=
MAL_SUCCEED) { //check
BBPunfix(outBAT->batCacheid);
- ret = createException(MAL, "batgeom.MakePoint", "%s",
err);
- GDKfree(err);
-
goto clean;
}
BUNappend(outBAT,pointWKB,TRUE); //add the result to the outBAT
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list