diff --git a/ChangeLog b/ChangeLog index 4e51577..1c2a03a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,14 @@ Thu Dec 30 19:26:01 CST 2004 Jeff Smith * src/gmdb/table_def.c: * src/gmdb2/debug.c: * 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 * include/mdbtools.h: Fix MdbSargTreeFunc's typedef diff --git a/src/gmdb/debug.c b/src/gmdb/debug.c index 207c840..be71d3e 100644 --- a/src/gmdb/debug.c +++ b/src/gmdb/debug.c @@ -389,11 +389,11 @@ GtkCTreeNode *node, *container; int namelen; namelen = fbuf[newbase]; - tmpstr = malloc(namelen + 1); + tmpstr = g_malloc(namelen + 1); strncpy(tmpstr, &fbuf[newbase+1], namelen); tmpstr[namelen]=0; 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); newbase += namelen + 1; } diff --git a/src/gmdb/sql.c b/src/gmdb/sql.c index a562992..6460993 100644 --- a/src/gmdb/sql.c +++ b/src/gmdb/sql.c @@ -112,9 +112,8 @@ gchar *titles[256]; return; } for (i=0;inum_columns;i++) { - bound_data[i] = (char *) malloc(MDB_BIND_SIZE); - bound_data[i][0] = '\0'; - mdbsql_bind_column(sql, i+1, bound_data[i]); + bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE); + mdb_sql_bind_column(sql, i+1, bound_data[i]); sqlcol = g_ptr_array_index(sql->columns,i); titles[i] = sqlcol->name; } @@ -132,7 +131,7 @@ gchar *titles[256]; /* free the memory used to bind */ for (i=0;inum_columns;i++) { - free(bound_data[i]); + g_free(bound_data[i]); } mdb_sql_reset(sql); diff --git a/src/gmdb/table_data.c b/src/gmdb/table_data.c index 7215478..a0ac7de 100644 --- a/src/gmdb/table_data.c +++ b/src/gmdb/table_data.c @@ -70,8 +70,7 @@ GMdbDataWindow *dataw = NULL; for (i=0;inum_cols;i++) { /* bind columns */ - bound_data[i] = (char *) malloc(MDB_BIND_SIZE); - bound_data[i][0] = '\0'; + bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE); mdb_bind_column(table, i+1, bound_data[i], NULL); /* display column titles */ @@ -87,7 +86,7 @@ GMdbDataWindow *dataw = NULL; /* free the memory used to bind */ for (i=0;inum_cols;i++) { - free(bound_data[i]); + g_free(bound_data[i]); } /* add this one to the window list */ diff --git a/src/gmdb/table_export.c b/src/gmdb/table_export.c index 8670717..2163121 100644 --- a/src/gmdb/table_export.c +++ b/src/gmdb/table_export.c @@ -105,8 +105,7 @@ char msg[100]; for (i=0;inum_cols;i++) { /* bind columns */ - bound_data[i] = (char *) malloc(MDB_BIND_SIZE); - bound_data[i][0] = '\0'; + bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE); mdb_bind_column(table, i+1, bound_data[i], NULL); /* display column titles */ @@ -134,7 +133,7 @@ char msg[100]; /* free the memory used to bind */ for (i=0;inum_cols;i++) { - free(bound_data[i]); + g_free(bound_data[i]); } fclose(outfile); diff --git a/src/gmdb2/debug.c b/src/gmdb2/debug.c index 4fcee10..a1f6b9b 100644 --- a/src/gmdb2/debug.c +++ b/src/gmdb2/debug.c @@ -819,11 +819,11 @@ GtkTreeIter *node, *container; int namelen; namelen = fbuf[newbase]; - tmpstr = malloc(namelen + 1); + tmpstr = g_malloc(namelen + 1); strncpy(tmpstr, &fbuf[newbase+1], namelen); tmpstr[namelen]=0; 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); newbase += namelen + 1; } @@ -847,12 +847,12 @@ GtkTreeIter *node, *container; int namelen; namelen = fbuf[newbase]; - tmpstr = malloc(namelen + 1); + tmpstr = g_malloc(namelen + 1); strncpy(tmpstr, &fbuf[newbase+1], namelen); tmpstr[namelen]=0; snprintf(str, 100, "Index %d: %s", i+1, tmpstr); node = gmdb_debug_add_item(store, container, str, newbase+1, newbase+namelen); - free(tmpstr); + g_free(tmpstr); newbase += namelen + 1; } } diff --git a/src/gmdb2/sql.c b/src/gmdb2/sql.c index e7c6d61..5e418a0 100644 --- a/src/gmdb2/sql.c +++ b/src/gmdb2/sql.c @@ -448,8 +448,7 @@ gmdb_sql_execute_cb(GtkWidget *w, GladeXML *xml) renderer = gtk_cell_renderer_text_new(); for (i=0;inum_columns;i++) { - bound_data[i] = (char *) malloc(MDB_BIND_SIZE); - bound_data[i][0] = '\0'; + bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE); mdb_sql_bind_column(sql, i+1, bound_data[i], NULL); sqlcol = g_ptr_array_index(sql->columns,i); 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 */ for (i=0;inum_columns;i++) { - free(bound_data[i]); + g_free(bound_data[i]); } mdb_sql_reset(sql); diff --git a/src/gmdb2/table_data.c b/src/gmdb2/table_data.c index 1b319cb..a2d641a 100644 --- a/src/gmdb2/table_data.c +++ b/src/gmdb2/table_data.c @@ -88,8 +88,7 @@ GMdbDataWindow *dataw = NULL; for (i=0;inum_cols;i++) { /* bind columns */ - bound_data[i] = (char *) malloc(MDB_BIND_SIZE); - bound_data[i][0] = '\0'; + bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE); mdb_bind_column(table, i+1, bound_data[i], NULL); /* display column titles */ @@ -110,7 +109,7 @@ GMdbDataWindow *dataw = NULL; /* free the memory used to bind */ for (i=0;inum_cols;i++) { - free(bound_data[i]); + g_free(bound_data[i]); } /* add this one to the window list */ diff --git a/src/gmdb2/table_export.c b/src/gmdb2/table_export.c index f4f5010..b840822 100644 --- a/src/gmdb2/table_export.c +++ b/src/gmdb2/table_export.c @@ -188,8 +188,7 @@ int rows=0; for (i=0;inum_cols;i++) { /* bind columns */ - bound_data[i] = (char *) malloc(MDB_BIND_SIZE); - bound_data[i][0] = '\0'; + bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE); mdb_bind_column(table, i+1, bound_data[i], NULL); /* display column titles */ @@ -217,7 +216,7 @@ int rows=0; /* free the memory used to bind */ for (i=0;inum_cols;i++) { - free(bound_data[i]); + g_free(bound_data[i]); } fclose(outfile);