Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7031/src/mal
Modified Files:
Tag: MonetDB_5-2
mal_import.mx
Log Message:
fix one more memory leak
Index: mal_import.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_import.mx,v
retrieving revision 1.70
retrieving revision 1.70.2.1
diff -u -d -r1.70 -r1.70.2.1
--- mal_import.mx 19 Aug 2007 16:34:02 -0000 1.70
+++ mal_import.mx 27 Oct 2007 07:52:42 -0000 1.70.2.1
@@ -245,6 +245,21 @@
@:restoreClient()@
return msg;
}
+
+str mal_cmdline( char *s, int *len)
+{
+ if (s[*len - 1] != '\n') {
+ char *n = GDKmalloc(*len + 1 + 1);
+
+ strncpy(n, s, *len);
+ n[*len] = '\n';
+ n[*len + 1] = 0;
+ (*len)++;
+ return n;
+ }
+ return s;
+}
+
@h
mal_export str compileString(Symbol *fcn, Client c, str s);
@c
@@ -255,6 +270,7 @@
buffer *b;
str msg = MAL_SUCCEED;
str qry;
+ str old = s;
c->yycur = 0;
c->prompt = GDKstrdup(""); /* do not produce visible prompts */
@@ -264,18 +280,11 @@
c->fdin = NULL;
c->srcFile= NULL;
- b = (buffer *) GDKmalloc(sizeof(buffer));
- if (s[len - 1] != '\n') {
- char *n = GDKmalloc(len + 1 + 1);
-
- strncpy(n, s, len);
- n[len] = '\n';
- n[len + 1] = 0;
- s = n;
- len++;
- }
- if( *s== '"') s++;
+ s = mal_cmdline(s, &len);
mal_unquote(qry = GDKstrdup(s));
+ if (old != s)
+ GDKfree(s);
+ b = (buffer *) GDKmalloc(sizeof(buffer));
buffer_init(b, qry, len);
MCpushClientInput(c, bstream_create(buffer_rastream(b,
"compileString"), b->len), 0, "");
MSinitClientPrg(c,"user", "main"); /* create new context */
@@ -301,6 +310,7 @@
c->nspace = oldnspace;
c->curprg = oldprg;
GDKfree(qry);
+ GDKfree(b);
return MAL_SUCCEED;
}
@@ -314,6 +324,7 @@
int len = strlen(s);
buffer *b;
str msg = MAL_SUCCEED,qry;
+ str old = s;
c->yycur = 0;
c->prompt = GDKstrdup(""); /* do not produce visible prompts */
@@ -323,18 +334,11 @@
c->fdin = NULL;
c->srcFile= NULL;
- b = (buffer *) GDKmalloc(sizeof(buffer));
- if (s[len - 1] != '\n') {
- char *n = GDKmalloc(len + 1 + 1);
-
- strncpy(n, s, len);
- n[len] = '\n';
- n[len + 1] = 0;
- s = n;
- len++;
- }
- if( *s=='"') s++;
+ s = mal_cmdline(s, &len);
mal_unquote(qry = GDKstrdup(s));
+ if (old != s)
+ GDKfree(s);
+ b = (buffer *) GDKmalloc(sizeof(buffer));
buffer_init(b, qry, len);
MCpushClientInput(c, bstream_create(buffer_rastream(b, "callString"),
b->len), listing, "");
MSinitClientPrg(c,"user", "main"); /* create new context */
@@ -347,6 +351,7 @@
@:runPhase(MAL_SCENARIO_ENGINE,restoreClient2)@
@:restoreClient2()@
GDKfree(qry);
+ GDKfree(b);
}
@h
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins