mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Move table and column functions to table.c
This commit is contained in:
parent
8e665e09e9
commit
fc25bde6ca
@ -1,3 +1,8 @@
|
||||
Wed Jun 23 07:30:17 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||
* src/libmdb/table.c:
|
||||
* src/libmdb/mem.c
|
||||
* include/mdbtools.h: Move table and column functions to table.c
|
||||
|
||||
Tue Jun 22 22:02:02 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||
* src/util/mdb-schema.c: Fix a memory leak
|
||||
* src/libmdb/mem.c: Fix another memory leak
|
||||
|
@ -384,10 +384,6 @@ extern void mdb_init();
|
||||
extern void mdb_exit();
|
||||
extern MdbStatistics *mdb_alloc_stats(MdbHandle *mdb);
|
||||
extern void mdb_free_stats(MdbHandle *mdb);
|
||||
extern MdbTableDef *mdb_alloc_tabledef(MdbCatalogEntry *entry);
|
||||
extern void mdb_free_tabledef(MdbTableDef *table);
|
||||
extern void mdb_append_column(GPtrArray *columns, MdbColumn *in_col);
|
||||
extern void mdb_free_columns(GPtrArray *columns);
|
||||
|
||||
/* file.c */
|
||||
extern size_t mdb_read_pg(MdbHandle *mdb, unsigned long pg);
|
||||
@ -420,7 +416,11 @@ extern char *mdb_get_objtype_string(int obj_type);
|
||||
extern void mdb_dump_catalog(MdbHandle *mdb, int obj_type);
|
||||
|
||||
/* table.c */
|
||||
extern MdbTableDef *mdb_alloc_tabledef(MdbCatalogEntry *entry);
|
||||
extern void mdb_free_tabledef(MdbTableDef *table);
|
||||
extern MdbTableDef *mdb_read_table(MdbCatalogEntry *entry);
|
||||
extern void mdb_append_column(GPtrArray *columns, MdbColumn *in_col);
|
||||
extern void mdb_free_columns(GPtrArray *columns);
|
||||
extern GPtrArray *mdb_read_columns(MdbTableDef *table);
|
||||
extern void mdb_table_dump(MdbCatalogEntry *entry);
|
||||
extern guint16 read_pg_if_16(MdbHandle *mdb, int *cur_pos);
|
||||
|
@ -64,42 +64,3 @@ mdb_free_stats(MdbHandle *mdb)
|
||||
g_free(mdb->stats);
|
||||
mdb->stats = NULL;
|
||||
}
|
||||
|
||||
MdbTableDef *mdb_alloc_tabledef(MdbCatalogEntry *entry)
|
||||
{
|
||||
MdbTableDef *table;
|
||||
|
||||
table = (MdbTableDef *) g_malloc0(sizeof(MdbTableDef));
|
||||
table->entry=entry;
|
||||
strcpy(table->name, entry->object_name);
|
||||
|
||||
return table;
|
||||
}
|
||||
void
|
||||
mdb_free_tabledef(MdbTableDef *table)
|
||||
{
|
||||
if (!table) return;
|
||||
mdb_free_columns(table->columns);
|
||||
g_free(table->usage_map);
|
||||
g_free(table->free_usage_map);
|
||||
g_free(table);
|
||||
}
|
||||
|
||||
void
|
||||
mdb_append_column(GPtrArray *columns, MdbColumn *in_col)
|
||||
{
|
||||
MdbColumn *col;
|
||||
|
||||
col = g_memdup(in_col,sizeof(MdbColumn));
|
||||
g_ptr_array_add(columns, col);
|
||||
}
|
||||
void
|
||||
mdb_free_columns(GPtrArray *columns)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!columns) return;
|
||||
for (i=0; i<columns->len; i++)
|
||||
g_free (g_ptr_array_index(columns, i));
|
||||
g_ptr_array_free(columns, TRUE);
|
||||
}
|
||||
|
@ -43,8 +43,25 @@ unsigned char mdb_col_needs_size(int col_type)
|
||||
}
|
||||
}
|
||||
|
||||
MdbTableDef *
|
||||
mdb_read_table(MdbCatalogEntry *entry)
|
||||
MdbTableDef *mdb_alloc_tabledef(MdbCatalogEntry *entry)
|
||||
{
|
||||
MdbTableDef *table;
|
||||
|
||||
table = (MdbTableDef *) g_malloc0(sizeof(MdbTableDef));
|
||||
table->entry=entry;
|
||||
strcpy(table->name, entry->object_name);
|
||||
|
||||
return table;
|
||||
}
|
||||
void mdb_free_tabledef(MdbTableDef *table)
|
||||
{
|
||||
if (!table) return;
|
||||
mdb_free_columns(table->columns);
|
||||
g_free(table->usage_map);
|
||||
g_free(table->free_usage_map);
|
||||
g_free(table);
|
||||
}
|
||||
MdbTableDef *mdb_read_table(MdbCatalogEntry *entry)
|
||||
{
|
||||
MdbTableDef *table;
|
||||
MdbHandle *mdb = entry->mdb;
|
||||
@ -155,6 +172,19 @@ read_pg_if_n(MdbHandle *mdb, unsigned char *buf, int *cur_pos, int len)
|
||||
}
|
||||
}
|
||||
|
||||
void mdb_append_column(GPtrArray *columns, MdbColumn *in_col)
|
||||
{
|
||||
g_ptr_array_add(columns, g_memdup(in_col,sizeof(MdbColumn)));
|
||||
}
|
||||
void mdb_free_columns(GPtrArray *columns)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!columns) return;
|
||||
for (i=0; i<columns->len; i++)
|
||||
g_free (g_ptr_array_index(columns, i));
|
||||
g_ptr_array_free(columns, TRUE);
|
||||
}
|
||||
GPtrArray *mdb_read_columns(MdbTableDef *table)
|
||||
{
|
||||
MdbHandle *mdb = table->entry->mdb;
|
||||
|
Loading…
Reference in New Issue
Block a user