Changeset: d3056dee0050 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d3056dee0050
Modified Files:
geom/monetdb5/geom.mx
Branch: Dec2011
Log Message:
Fix reading/writing object of type mbr.
An mbr consists of 4 flt values which were cast to int to be written
and read as int and then cast to flt. This means that values that
don't fit in an int (decimals, out of range, flt_nil) were not read
and written correctly. This in turn meant that the WAL was useless
for values of type mbr (which is where this is used).
The old code (pre 2007) did it correctly, but not in a way that
satisfied compilers.
If a compiler starts complaining about the call to mnstr_readIntArray
or mnstr_writeIntArray, use an int v[4] array and memcpy the values to
and from this array before writing or after reading.
diffs (50 lines):
diff --git a/geom/monetdb5/geom.mx b/geom/monetdb5/geom.mx
--- a/geom/monetdb5/geom.mx
+++ b/geom/monetdb5/geom.mx
@@ -451,18 +451,15 @@ mbrREAD(mbr *a, stream *s, size_t cnt)
{
mbr *c;
size_t i;
- int xmin, ymin, xmax, ymax;
+ flt vals[4];
for (i = 0, c = a; i < cnt; i++, c++) {
- if (!mnstr_readInt(s, &xmin) ||
- !mnstr_readInt(s, &ymin) ||
- !mnstr_readInt(s, &xmax) ||
- !mnstr_readInt(s, &ymax))
+ if (!mnstr_readIntArray(s, (int *) vals, 4))
return NULL;
- c->xmin = (flt) xmin;
- c->ymin = (flt) ymin;
- c->xmax = (flt) xmax;
- c->ymax = (flt) ymax;
+ c->xmin = vals[0];
+ c->ymin = vals[1];
+ c->xmax = vals[2];
+ c->ymax = vals[3];
}
return a;
}
@@ -473,15 +470,14 @@ int
mbrWRITE(mbr *c, stream *s, size_t cnt)
{
size_t i;
+ flt vals[4];
for (i = 0; i < cnt; i++, c++) {
- /* use binary writeInt (as sizeof (flt) == sizeof(int)); */
- /* We want to write nil's here too.
- So no overflow checking needed */
- if (!mnstr_writeInt(s, (int) c->xmin) ||
- !mnstr_writeInt(s, (int) c->ymin) ||
- !mnstr_writeInt(s, (int) c->xmax) ||
- !mnstr_writeInt(s, (int) c->ymax))
+ vals[0] = c->xmin;
+ vals[1] = c->ymin;
+ vals[2] = c->xmax;
+ vals[3] = c->ymax;
+ if (!mnstr_writeIntArray(s, (int *) vals, 4))
return GDK_FAIL;
}
return GDK_SUCCEED;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list