Update of /cvsroot/monetdb/pathfinder/compiler/sql
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21153/compiler/sql
Modified Files:
Tag: XQuery_0-22
sql.c
Log Message:
This is a fix for bug [ 1892554 ] PF: loading pre-compiled MIL modules
fails on Windows
There seems to a difference between Windows and Linux in the meaning
of the second argument of snprintf and vsnprintf: in Linux this
argument gives the size of the buffer to which the function writes,
whereas in Windows it gives the number of non-NULL bytes that it can
write (and then it adds a NULL). This means that on Windows you have
to specify a size which is *smaller* than the actual size of the
buffer.
To make the same code work on both flavors, in some cases we now
overallocate the needed space by one byte so that we can use
(sizeof(buf)-1) as size.
Index: sql.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/sql/sql.c,v
retrieving revision 1.48.4.1
retrieving revision 1.48.4.2
diff -u -d -r1.48.4.1 -r1.48.4.2
--- sql.c 8 Feb 2008 13:03:57 -0000 1.48.4.1
+++ sql.c 22 Feb 2008 10:39:28 -0000 1.48.4.2
@@ -1230,7 +1230,7 @@
default:
{
size_t len = sizeof ("t0000");
- char *res = (char *) PFmalloc (len);
+ char *res = (char *) PFmalloc (len+1);
/* to express table names we use
* the following format:
* t[0-9][0-9][0-9][0-9]
@@ -1261,7 +1261,7 @@
default:
{
size_t len = sizeof ("a0000");
- char *res = (char *) PFmalloc (len);
+ char *res = (char *) PFmalloc (len+1);
/* to express alias names we use
* the following format:
* a[0-9][0-9][0-9][0-9]
@@ -1314,7 +1314,7 @@
case sql_col_max: return "max";
case sql_col_dist:
assert (name->ty < 100);
- res = (char *) PFmalloc (7 * sizeof (char));
+ res = (char *) PFmalloc (8);
snprintf (res, 7, "dist%02u", name->ty);
return res;
}
@@ -1323,7 +1323,7 @@
char *tystr = PFalg_simple_type_str (name->ty);
size_t len = strlen (attstr) + strlen (tystr) + 2;
- res = (char *) PFmalloc (len * sizeof (char));
+ res = (char *) PFmalloc (len + 1);
snprintf (res, len, "%s_%s", attstr, tystr);
}
return res;
-------------------------------------------------------------------------
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-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins