Update of /cvsroot/monetdb/MonetDB/src/gdk
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13946/src/gdk
Modified Files:
Tag: MonetDB_1-22
gdk_batop.mx
Log Message:
fixed bug
[ 1886508 ] PF: many (most?) tests fail after recent checkins
http://sourceforge.net/tracker/index.php?func=detail&aid=1886508&group_id=56967&atid=482468
After Niels's "klokwork"-suggested fixes on Fri Feb 01 2008
(cf., MonetDB/src/gdk/gdk_batop.mx 1.149 -> 1.150),
BATrevert return NULL due to a GDKmalloc(0) returning 0,
in case BATrevert was called on a BAT with a void-nil head or tail.
Fix: BATrevert does not have to do anything for an *empty* void-nil
head of tail, thus avoiding the GDKmalloc(0).
Index: gdk_batop.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/gdk/gdk_batop.mx,v
retrieving revision 1.150
retrieving revision 1.150.2.1
diff -u -d -r1.150 -r1.150.2.1
--- gdk_batop.mx 1 Feb 2008 12:21:35 -0000 1.150
+++ gdk_batop.mx 8 Feb 2008 05:51:28 -0000 1.150.2.1
@@ -1681,31 +1681,36 @@
return NULL;
}
ALIGNdel(b, "BATrevert", FALSE);
- hs = (size_t) Hsize(b);
- ts = (size_t) Tsize(b);
- h = (char *) GDKmalloc(hs);
- t = (char *) GDKmalloc(ts);
- if (!h || !t) {
+ if ((hs = (size_t) Hsize(b)) > 0) {
+ h = (char *) GDKmalloc(hs);
+ if (!h) {
+ return NULL;
+ }
+ for (p = BUNlast(b)?BUNlast(b) - 1:0, q = BUNfirst(b); p > q;
p--, q++){
+ char *ph = BUNhloc(bi,p);
+ char *qh = BUNhloc(bi,q);
+
+ memcpy(h , ph, hs);
+ memcpy(ph, qh, hs);
+ memcpy(qh, h , hs);
+ }
GDKfree(h);
- GDKfree(t);
- return NULL;
}
- for (p = BUNlast(b)?BUNlast(b) - 1:0, q = BUNfirst(b); p > q; p--, q++){
- char *ph = BUNhloc(bi,p);
- char *qh = BUNhloc(bi,q);
- char *pt = BUNtloc(bi,p);
- char *qt = BUNtloc(bi,q);
-
- memcpy(h , ph, hs);
- memcpy(ph, qh, hs);
- memcpy(qh, h , hs);
+ if ((ts = (size_t) Tsize(b)) > 0) {
+ t = (char *) GDKmalloc(ts);
+ if (!t) {
+ return NULL;
+ }
+ for (p = BUNlast(b)?BUNlast(b) - 1:0, q = BUNfirst(b); p > q;
p--, q++){
+ char *pt = BUNtloc(bi,p);
+ char *qt = BUNtloc(bi,q);
- memcpy(h , pt, ts);
- memcpy(pt, qt, ts);
- memcpy(qt, h , ts);
+ memcpy(t , pt, ts);
+ memcpy(pt, qt, ts);
+ memcpy(qt, t , ts);
+ }
+ GDKfree(t);
}
- GDKfree(h);
- GDKfree(t);
HASHdestroy(b);
if (b->hsorted & GDK_SORTED)
b->hsorted = GDK_SORTED_REV;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins