Fix several leaks and errors

This commit is contained in:
whydoubt
2005-11-09 13:24:26 +00:00
parent de1ce907a4
commit 278b6e284c
5 changed files with 17 additions and 7 deletions

View File

@@ -1,3 +1,9 @@
Wed Nov 9 07:23:01 CST 2005 Jeff Smith <whydoubt@yahoo.com>
* src/util/mdb-array.c:
* src/util/mdb-header.c:
* src/util/mdb-sql.c:
* src/sql/parser.y: Fix several leaks and errors
Fri Nov 4 06:10:41 CST 2005 Jeff Smith <whydoubt@yahoo.com> Fri Nov 4 06:10:41 CST 2005 Jeff Smith <whydoubt@yahoo.com>
* src/libmdb/data.c: Fix in reading bound boolean fields (Yasir Assam) * src/libmdb/data.c: Fix in reading bound boolean fields (Yasir Assam)
* src/libmdb/data.c: Several more fixes in reading data into bound fields * src/libmdb/data.c: Several more fixes in reading data into bound fields

View File

@@ -102,6 +102,8 @@ sarg:
} }
| constant operator constant { | constant operator constant {
mdb_sql_eval_expr(_mdb_sql(NULL), $1, $2, $3); mdb_sql_eval_expr(_mdb_sql(NULL), $1, $2, $3);
free($1);
free($3);
} }
| identifier nulloperator { | identifier nulloperator {
mdb_sql_add_sarg(_mdb_sql(NULL), $1, $2, NULL); mdb_sql_add_sarg(_mdb_sql(NULL), $1, $2, NULL);

View File

@@ -38,10 +38,10 @@ MdbColumn *col;
char *bound_values [256]; char *bound_values [256];
char delimiter [] = ", "; char delimiter [] = ", ";
char quote_text = 1; char quote_text = 1;
int count; int count = 0;
int started; int started;
if (argc < 2) if (argc < 3)
{ {
fprintf (stderr, "Usage: %s <file> <table>\n", argv [0]); fprintf (stderr, "Usage: %s <file> <table>\n", argv [0]);
exit (1); exit (1);
@@ -109,19 +109,19 @@ int started;
fprintf (stdout, "}"); fprintf (stdout, "}");
count++; count++;
} }
fprintf (stdout, "\n};\n\n");
for (j = 0; j < table->num_cols; j++) for (j = 0; j < table->num_cols; j++)
{ {
g_free (bound_values [j]); g_free (bound_values [j]);
} }
mdb_free_tabledef(table); mdb_free_tabledef(table);
} }
mdb_close (mdb); mdb_close (mdb);
mdb_exit(); mdb_exit();
fprintf (stdout, "\n};\n"); fprintf (stdout, "const int %s_array_length = %d;\n",
fprintf (stdout, "\nconst int %s_array_length = %d;\n",
argv [2], argv [2],
count); count);

View File

@@ -139,6 +139,7 @@ FILE *cfile;
mdb_free_tabledef(table); mdb_free_tabledef(table);
} }
fclose (headerfile);
fclose (typesfile); fclose (typesfile);
fclose (cfile); fclose (cfile);

View File

@@ -430,7 +430,8 @@ char *delimiter = NULL;
if ((!s) || (!fgets(s, 256, in))) { if ((!s) || (!fgets(s, 256, in))) {
/* if we have something in the buffer, run it */ /* if we have something in the buffer, run it */
if (strlen(mybuf)) if (strlen(mybuf))
run_query(out, sql, mybuf, delimiter); run_query((out) ? out : stdout,
sql, mybuf, delimiter);
break; break;
} }
if (s[strlen(s)-1]=='\n') if (s[strlen(s)-1]=='\n')
@@ -450,7 +451,7 @@ char *delimiter = NULL;
line = 0; line = 0;
} else if (!strcmp(s,"go")) { } else if (!strcmp(s,"go")) {
line = 0; line = 0;
run_query(out, sql, mybuf, delimiter); run_query((out) ? out : stdout, sql, mybuf, delimiter);
mybuf[0]='\0'; mybuf[0]='\0';
} else if (!strcmp(s,"reset")) { } else if (!strcmp(s,"reset")) {
line = 0; line = 0;