Fixed. Jan Flokstra wrote: > I have great compilation troubles with the last lesson from the master:-) The > compiler doesn not know the realloc() and the malloc() function() in the > current setting. When I change them into PFrealloc() and PFmalloc() it > compiles. But then I still have problems with the "free(buf);" line. There is > no PFfree(); and I think GDKfree() will not always work, > > JanF. > > On Tuesday 01 May 2007 17:58, Sjoerd Mullender wrote: >> Update of /cvsroot/monetdb/pathfinder/compiler/mil >> In directory sc8-pr-cvs16:/tmp/cvs-serv17830 >> >> Modified Files: >> milprint_summer.c >> Log Message: >> When you want to use a library function, make sure the appropriate >> include file is included. For alloca there is an extra twist: for the >> way to include alloca.h see e.g. monet_utils.mx. Do not hide the lack >> of a declaration with a cast. The compiler then thinks the function >> returns an int which may well be smaller in space than the actual >> value, and hence some bytes of the value may get lost. >> >> Having said this, alloca should *not* be used in a loop. It allocates >> memory in each iteration which is only freed at the end of the >> function. If the loop loops many times, that can be a lot of memory >> which is allocated on the stack (which is a very finite resource!). >> >> Here ends today's lesson. >> >> >> Index: milprint_summer.c >> =================================================================== >> RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint_summer.c,v >> retrieving revision 1.367 >> retrieving revision 1.368 >> diff -u -d -r1.367 -r1.368 >> --- milprint_summer.c 27 Apr 2007 18:22:40 -0000 1.367 >> +++ milprint_summer.c 1 May 2007 15:57:59 -0000 1.368 >> @@ -11140,12 +11140,18 @@ >> /* ============================= */ >> /* initialize function variables */ >> /* ============================= */ >> + size_t maxbufsize = 0; >> + char *buf = NULL; >> while (args->kind != c_nil) >> { >> /* get the type name, and assure there *is* a namespace */ >> char *tpe = PFty_str(TY(LR(args))); >> - char *buf = (char*) alloca(4+strlen(tpe)); >> - char *nme = buf; >> + char *nme; >> + if (maxbufsize < strlen(tpe) + 4) { >> + maxbufsize = strlen(tpe) + 4; >> + buf = buf ? realloc(buf, maxbufsize) : malloc(maxbufsize); >> + } >> + nme = buf; >> if (strchr(tpe, ':') == NULL) { >> *buf++ = 'x'; >> *buf++ = 's'; >> @@ -11171,6 +11177,8 @@ >> >> args = R(args); >> } >> + if (buf) >> + free(buf); >> /* create the full signature that also is a valid MIL identifier >> */ c->sem.fun->sig = PFmalloc(12+3*(strlen(sig)+strlen(p))); >> >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> _______________________________________________ >> Monetdb-pf-checkins mailing list >> [EMAIL PROTECTED] >> https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Monetdb-pf-checkins mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins
-- Sjoerd Mullender
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
_______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers