mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Fixed MDBProps memory leaks
This commit is contained in:
parent
23942c19d3
commit
fd6e52f9bd
@ -48,11 +48,21 @@ static char *type_name[] = {"Form",
|
||||
|
||||
void mdb_free_catalog(MdbHandle *mdb)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int i, j;
|
||||
MdbCatalogEntry *entry;
|
||||
|
||||
if ((!mdb) || (!mdb->catalog)) return;
|
||||
for (i=0; i<mdb->catalog->len; i++)
|
||||
g_free (g_ptr_array_index(mdb->catalog, i));
|
||||
for (i=0; i<mdb->catalog->len; i++) {
|
||||
entry = (MdbCatalogEntry *)g_ptr_array_index(mdb->catalog, i);
|
||||
if (entry) {
|
||||
if (entry->props) {
|
||||
for (j=0; j<entry->props->len; j++)
|
||||
mdb_free_props(g_array_index(entry->props, MdbProperties*, j));
|
||||
g_array_free(entry->props, TRUE);
|
||||
}
|
||||
g_free(entry);
|
||||
}
|
||||
}
|
||||
g_ptr_array_free(mdb->catalog, TRUE);
|
||||
mdb->catalog = NULL;
|
||||
}
|
||||
|
@ -50,12 +50,23 @@ mdb_read_props_list(MdbHandle *mdb, gchar *kkd, int len)
|
||||
}
|
||||
return names;
|
||||
}
|
||||
static gboolean
|
||||
free_hash_entry(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
g_free(key);
|
||||
g_free(value);
|
||||
return TRUE;
|
||||
}
|
||||
void
|
||||
mdb_free_props(MdbProperties *props)
|
||||
{
|
||||
if (!props) return;
|
||||
|
||||
if (props->name) g_free(props->name);
|
||||
if (props->hash) {
|
||||
g_hash_table_foreach(props->hash, (GHFunc)free_hash_entry, 0);
|
||||
g_hash_table_destroy(props->hash);
|
||||
}
|
||||
g_free(props);
|
||||
}
|
||||
|
||||
@ -148,7 +159,7 @@ mdb_dump_props(MdbProperties *props, FILE *outfile, int show_name) {
|
||||
/*
|
||||
* That function takes a raw KKD/MR2 binary buffer,
|
||||
* typically read from LvProp in table MSysbjects
|
||||
* and returns a GPtrArray of MdbProps*
|
||||
* and returns a GArray of MdbProps*
|
||||
*/
|
||||
GArray*
|
||||
mdb_kkd_to_props(MdbHandle *mdb, void *buffer, size_t len) {
|
||||
|
Loading…
Reference in New Issue
Block a user