Changeset: 0864135729fe for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0864135729fe
Modified Files:
sql/backends/monet5/UDF/udf.c
Branch: Aug2011
Log Message:
udf: uncrustify
diffs (120 lines):
diff --git a/sql/backends/monet5/UDF/udf.c b/sql/backends/monet5/UDF/udf.c
--- a/sql/backends/monet5/UDF/udf.c
+++ b/sql/backends/monet5/UDF/udf.c
@@ -29,71 +29,74 @@ reverse(str src)
/* The scalar function returns the new space */
len = (int) strlen(src);
- ret = new = GDKzalloc( len + 1);
- for(len--; len >= 0; len--)
+ ret = new = GDKzalloc(len + 1);
+ for (len--; len >= 0; len--)
*new++ = src[len];
return ret;
}
-str
+str
UDFreverse(str *ret, str *src)
{
- if( *src == 0 || strcmp(*src, str_nil) == 0 )
- *ret = GDKstrdup(str_nil);
- else *ret = reverse(*src);
+ if (*src == 0 || strcmp(*src, str_nil) == 0)
+ *ret = GDKstrdup(str_nil);
+ else
+ *ret = reverse(*src);
return MAL_SUCCEED;
}
-/*
+/*
* The BAT version is much more complicated, because we need to
* ensure that properties are maintained.
-*/
+ */
str UDFBATreverse(int *ret, int *bid)
{
- BATiter li;
- BAT *bn, *left;
- BUN p,q;
- str v;
+ BATiter li;
+ BAT *bn, *left;
+ BUN p, q;
+ str v;
/* locate the BAT in the buffer pool */
- if( (left= BATdescriptor(*bid)) == NULL )
- throw(MAL, "mal.reverse" , RUNTIME_OBJECT_MISSING);
+ if ((left = BATdescriptor(*bid)) == NULL)
+ throw(MAL, "mal.reverse", RUNTIME_OBJECT_MISSING);
/* create the result container */
- bn= BATnew(left->htype,TYPE_str,BATcount(left));
- if (left->htype== TYPE_void)
- BATseqbase(bn, left->hseqbase);
- if (bn == NULL){
- BBPreleaseref(left->batCacheid);
- throw(MAL, "mal.reverse", MAL_MALLOC_FAIL);
- }
+ bn = BATnew(left->htype, TYPE_str, BATcount(left));
+ if (left->htype == TYPE_void)
+ BATseqbase(bn, left->hseqbase);
+ if (bn == NULL) {
+ BBPreleaseref(left->batCacheid);
+ throw(MAL, "mal.reverse", MAL_MALLOC_FAIL);
+ }
/* manage the properties of the result */
- bn->hsorted= left->hsorted;
- bn->tsorted=0; /* assume not sorted afterwards */
+ bn->hsorted = left->hsorted;
+ bn->tsorted = 0; /* assume not sorted afterwards */
- li = bat_iterator(left);
+ li = bat_iterator(left);
/* advice on sequential scan */
- BATaccessBegin(left, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL);
+ BATaccessBegin(left, USE_HEAD | USE_TAIL, MMAP_SEQUENTIAL);
/* the core of the algorithm, expensive due to malloc/frees */
- BATloop(left, p, q) {
- ptr h = BUNhead(li,p);
- str tl = (str) BUNtail(li,p);
- v= reverse(tl);
- bunfastins(bn, h, v);
- GDKfree(v);
- }
- BATaccessEnd(left, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL);
- if (!(bn->batDirty & 2)) (bn) = BATsetaccess(bn, BAT_READ);
- *ret = (bn)->batCacheid;
- BBPkeepref(*ret);
- BBPreleaseref(left->batCacheid);
- return MAL_SUCCEED;
+ BATloop(left, p, q)
+ {
+ ptr h = BUNhead(li, p);
+ str tl = (str) BUNtail(li, p);
+ v = reverse(tl);
+ bunfastins(bn, h, v);
+ GDKfree(v);
+ }
+ BATaccessEnd(left, USE_HEAD | USE_TAIL, MMAP_SEQUENTIAL);
+ if (!(bn->batDirty & 2))
+ (bn) = BATsetaccess(bn, BAT_READ);
+ *ret = (bn)->batCacheid;
+ BBPkeepref(*ret);
+ BBPreleaseref(left->batCacheid);
+ return MAL_SUCCEED;
bunins_failed:
- BATaccessEnd(left, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL);
- BBPreleaseref(left->batCacheid);
- BBPreleaseref(*ret);
- throw(MAL, "mal.reverse", OPERATION_FAILED " During bulk operation");
+ BATaccessEnd(left, USE_HEAD | USE_TAIL, MMAP_SEQUENTIAL);
+ BBPreleaseref(left->batCacheid);
+ BBPreleaseref(*ret);
+ throw(MAL, "mal.reverse", OPERATION_FAILED " During bulk operation");
}
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list