Replace malloc/free with g_malloc/g_free

This commit is contained in:
whydoubt
2004-12-31 05:25:11 +00:00
parent 680e997365
commit f09f9438d3
9 changed files with 27 additions and 25 deletions

View File

@@ -24,6 +24,14 @@ Thu Dec 30 19:26:01 CST 2004 Jeff Smith <whydoubt@yahoo.com>
* src/gmdb/table_def.c: * src/gmdb/table_def.c:
* src/gmdb2/debug.c: * src/gmdb2/debug.c:
* src/gmdb2/table_def.c: Replace malloc/memset with g_malloc0 * src/gmdb2/table_def.c: Replace malloc/memset with g_malloc0
* src/gmdb/debug.c:
* src/gmdb/sql.c:
* src/gmdb/table_data.c:
* src/gmdb/table_export.c:
* src/gmdb2/debug.c:
* src/gmdb2/sql.c:
* src/gmdb2/table_data.c:
* src/gmdb2/table_export.c: Replace malloc/free with g_malloc/g_free
Thu Dec 30 06:36:25 CST 2004 Jeff Smith <whydoubt@yahoo.com> Thu Dec 30 06:36:25 CST 2004 Jeff Smith <whydoubt@yahoo.com>
* include/mdbtools.h: Fix MdbSargTreeFunc's typedef * include/mdbtools.h: Fix MdbSargTreeFunc's typedef

View File

@@ -389,11 +389,11 @@ GtkCTreeNode *node, *container;
int namelen; int namelen;
namelen = fbuf[newbase]; namelen = fbuf[newbase];
tmpstr = malloc(namelen + 1); tmpstr = g_malloc(namelen + 1);
strncpy(tmpstr, &fbuf[newbase+1], namelen); strncpy(tmpstr, &fbuf[newbase+1], namelen);
tmpstr[namelen]=0; tmpstr[namelen]=0;
snprintf(str, 100, "Column %d: %s", i+1, tmpstr); snprintf(str, 100, "Column %d: %s", i+1, tmpstr);
free(tmpstr); g_free(tmpstr);
node = gmdb_debug_add_item(dbug, container, str, newbase + 1, newbase + namelen); node = gmdb_debug_add_item(dbug, container, str, newbase + 1, newbase + namelen);
newbase += namelen + 1; newbase += namelen + 1;
} }

View File

@@ -112,9 +112,8 @@ gchar *titles[256];
return; return;
} }
for (i=0;i<sql->num_columns;i++) { for (i=0;i<sql->num_columns;i++) {
bound_data[i] = (char *) malloc(MDB_BIND_SIZE); bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE);
bound_data[i][0] = '\0'; mdb_sql_bind_column(sql, i+1, bound_data[i]);
mdbsql_bind_column(sql, i+1, bound_data[i]);
sqlcol = g_ptr_array_index(sql->columns,i); sqlcol = g_ptr_array_index(sql->columns,i);
titles[i] = sqlcol->name; titles[i] = sqlcol->name;
} }
@@ -132,7 +131,7 @@ gchar *titles[256];
/* free the memory used to bind */ /* free the memory used to bind */
for (i=0;i<sql->num_columns;i++) { for (i=0;i<sql->num_columns;i++) {
free(bound_data[i]); g_free(bound_data[i]);
} }
mdb_sql_reset(sql); mdb_sql_reset(sql);

View File

@@ -70,8 +70,7 @@ GMdbDataWindow *dataw = NULL;
for (i=0;i<table->num_cols;i++) { for (i=0;i<table->num_cols;i++) {
/* bind columns */ /* bind columns */
bound_data[i] = (char *) malloc(MDB_BIND_SIZE); bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE);
bound_data[i][0] = '\0';
mdb_bind_column(table, i+1, bound_data[i], NULL); mdb_bind_column(table, i+1, bound_data[i], NULL);
/* display column titles */ /* display column titles */
@@ -87,7 +86,7 @@ GMdbDataWindow *dataw = NULL;
/* free the memory used to bind */ /* free the memory used to bind */
for (i=0;i<table->num_cols;i++) { for (i=0;i<table->num_cols;i++) {
free(bound_data[i]); g_free(bound_data[i]);
} }
/* add this one to the window list */ /* add this one to the window list */

View File

@@ -105,8 +105,7 @@ char msg[100];
for (i=0;i<table->num_cols;i++) { for (i=0;i<table->num_cols;i++) {
/* bind columns */ /* bind columns */
bound_data[i] = (char *) malloc(MDB_BIND_SIZE); bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE);
bound_data[i][0] = '\0';
mdb_bind_column(table, i+1, bound_data[i], NULL); mdb_bind_column(table, i+1, bound_data[i], NULL);
/* display column titles */ /* display column titles */
@@ -134,7 +133,7 @@ char msg[100];
/* free the memory used to bind */ /* free the memory used to bind */
for (i=0;i<table->num_cols;i++) { for (i=0;i<table->num_cols;i++) {
free(bound_data[i]); g_free(bound_data[i]);
} }
fclose(outfile); fclose(outfile);

View File

@@ -819,11 +819,11 @@ GtkTreeIter *node, *container;
int namelen; int namelen;
namelen = fbuf[newbase]; namelen = fbuf[newbase];
tmpstr = malloc(namelen + 1); tmpstr = g_malloc(namelen + 1);
strncpy(tmpstr, &fbuf[newbase+1], namelen); strncpy(tmpstr, &fbuf[newbase+1], namelen);
tmpstr[namelen]=0; tmpstr[namelen]=0;
snprintf(str, 100, "Column %d: %s", i+1, tmpstr); snprintf(str, 100, "Column %d: %s", i+1, tmpstr);
free(tmpstr); g_free(tmpstr);
node = gmdb_debug_add_item(store, container, str, newbase + 1, newbase + namelen); node = gmdb_debug_add_item(store, container, str, newbase + 1, newbase + namelen);
newbase += namelen + 1; newbase += namelen + 1;
} }
@@ -847,12 +847,12 @@ GtkTreeIter *node, *container;
int namelen; int namelen;
namelen = fbuf[newbase]; namelen = fbuf[newbase];
tmpstr = malloc(namelen + 1); tmpstr = g_malloc(namelen + 1);
strncpy(tmpstr, &fbuf[newbase+1], namelen); strncpy(tmpstr, &fbuf[newbase+1], namelen);
tmpstr[namelen]=0; tmpstr[namelen]=0;
snprintf(str, 100, "Index %d: %s", i+1, tmpstr); snprintf(str, 100, "Index %d: %s", i+1, tmpstr);
node = gmdb_debug_add_item(store, container, str, newbase+1, newbase+namelen); node = gmdb_debug_add_item(store, container, str, newbase+1, newbase+namelen);
free(tmpstr); g_free(tmpstr);
newbase += namelen + 1; newbase += namelen + 1;
} }
} }

View File

@@ -448,8 +448,7 @@ gmdb_sql_execute_cb(GtkWidget *w, GladeXML *xml)
renderer = gtk_cell_renderer_text_new(); renderer = gtk_cell_renderer_text_new();
for (i=0;i<sql->num_columns;i++) { for (i=0;i<sql->num_columns;i++) {
bound_data[i] = (char *) malloc(MDB_BIND_SIZE); bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE);
bound_data[i][0] = '\0';
mdb_sql_bind_column(sql, i+1, bound_data[i], NULL); mdb_sql_bind_column(sql, i+1, bound_data[i], NULL);
sqlcol = g_ptr_array_index(sql->columns,i); sqlcol = g_ptr_array_index(sql->columns,i);
column = gtk_tree_view_column_new_with_attributes(sqlcol->name, renderer, "text", i, NULL); column = gtk_tree_view_column_new_with_attributes(sqlcol->name, renderer, "text", i, NULL);
@@ -472,7 +471,7 @@ gmdb_sql_execute_cb(GtkWidget *w, GladeXML *xml)
/* free the memory used to bind */ /* free the memory used to bind */
for (i=0;i<sql->num_columns;i++) { for (i=0;i<sql->num_columns;i++) {
free(bound_data[i]); g_free(bound_data[i]);
} }
mdb_sql_reset(sql); mdb_sql_reset(sql);

View File

@@ -88,8 +88,7 @@ GMdbDataWindow *dataw = NULL;
for (i=0;i<table->num_cols;i++) { for (i=0;i<table->num_cols;i++) {
/* bind columns */ /* bind columns */
bound_data[i] = (char *) malloc(MDB_BIND_SIZE); bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE);
bound_data[i][0] = '\0';
mdb_bind_column(table, i+1, bound_data[i], NULL); mdb_bind_column(table, i+1, bound_data[i], NULL);
/* display column titles */ /* display column titles */
@@ -110,7 +109,7 @@ GMdbDataWindow *dataw = NULL;
/* free the memory used to bind */ /* free the memory used to bind */
for (i=0;i<table->num_cols;i++) { for (i=0;i<table->num_cols;i++) {
free(bound_data[i]); g_free(bound_data[i]);
} }
/* add this one to the window list */ /* add this one to the window list */

View File

@@ -188,8 +188,7 @@ int rows=0;
for (i=0;i<table->num_cols;i++) { for (i=0;i<table->num_cols;i++) {
/* bind columns */ /* bind columns */
bound_data[i] = (char *) malloc(MDB_BIND_SIZE); bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE);
bound_data[i][0] = '\0';
mdb_bind_column(table, i+1, bound_data[i], NULL); mdb_bind_column(table, i+1, bound_data[i], NULL);
/* display column titles */ /* display column titles */
@@ -217,7 +216,7 @@ int rows=0;
/* free the memory used to bind */ /* free the memory used to bind */
for (i=0;i<table->num_cols;i++) { for (i=0;i<table->num_cols;i++) {
free(bound_data[i]); g_free(bound_data[i]);
} }
fclose(outfile); fclose(outfile);