mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-01-21 18:48:34 +08:00
malloc to g_malloc for backend functions
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
Sat May 29 14:14:21 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||||
|
* src/libmdb/backend.c:
|
||||||
|
* src/libmdb/file.c: malloc to g_malloc for backend functions
|
||||||
|
|
||||||
Fri May 28 06:55:55 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
Fri May 28 06:55:55 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||||
* src/libmdb/mem.c: Fixed a couple of potential memory leaks
|
* src/libmdb/mem.c: Fixed a couple of potential memory leaks
|
||||||
* include/mdbtools.h: Fixed a couple of compiler warnings
|
* include/mdbtools.h: Fixed a couple of compiler warnings
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ int mdb_coltype_takes_length(MdbBackend *backend, int col_type)
|
|||||||
*/
|
*/
|
||||||
void mdb_init_backends()
|
void mdb_init_backends()
|
||||||
{
|
{
|
||||||
MdbBackend *backend;
|
MdbBackend *backend;
|
||||||
|
|
||||||
mdb_backends = g_hash_table_new(g_str_hash, g_str_equal);
|
mdb_backends = g_hash_table_new(g_str_hash, g_str_equal);
|
||||||
|
|
||||||
@@ -205,13 +205,12 @@ void mdb_remove_backends()
|
|||||||
}
|
}
|
||||||
int mdb_set_default_backend(MdbHandle *mdb, char *backend_name)
|
int mdb_set_default_backend(MdbHandle *mdb, char *backend_name)
|
||||||
{
|
{
|
||||||
MdbBackend *backend;
|
MdbBackend *backend;
|
||||||
|
|
||||||
backend = (MdbBackend *) g_hash_table_lookup(mdb_backends, backend_name);
|
backend = (MdbBackend *) g_hash_table_lookup(mdb_backends, backend_name);
|
||||||
if (backend) {
|
if (backend) {
|
||||||
mdb->default_backend = backend;
|
mdb->default_backend = backend;
|
||||||
mdb->backend_name = (char *) malloc(strlen(backend_name)+1);
|
mdb->backend_name = (char *) g_strdup(backend_name);
|
||||||
strcpy(mdb->backend_name, backend_name);
|
|
||||||
did_first = 0;
|
did_first = 0;
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -237,14 +236,14 @@ do_first (MdbHandle *mdb)
|
|||||||
mdb_read_columns(table);
|
mdb_read_columns(table);
|
||||||
mdb_rewind_table(table);
|
mdb_rewind_table(table);
|
||||||
for (k=0;k<table->num_cols;k++) {
|
for (k=0;k<table->num_cols;k++) {
|
||||||
bound_values[k] = (char *) malloc(MDB_BIND_SIZE);
|
bound_values[k] = (char *) g_malloc(MDB_BIND_SIZE);
|
||||||
bound_values[k][0] = '\0';
|
bound_values[k][0] = '\0';
|
||||||
mdb_bind_column(table,k+1,bound_values[k]);
|
mdb_bind_column(table,k+1,bound_values[k]);
|
||||||
}
|
}
|
||||||
relationships[0] = (char *) malloc(256); /* child column */
|
relationships[0] = (char *) g_malloc(256); /* child column */
|
||||||
relationships[1] = (char *) malloc(256); /* child table */
|
relationships[1] = (char *) g_malloc(256); /* child table */
|
||||||
relationships[2] = (char *) malloc(256); /* parent column */
|
relationships[2] = (char *) g_malloc(256); /* parent column */
|
||||||
relationships[3] = (char *) malloc(256); /* parent table */
|
relationships[3] = (char *) g_malloc(256); /* parent table */
|
||||||
} /* if num_rows > 0 */
|
} /* if num_rows > 0 */
|
||||||
did_first = 1;
|
did_first = 1;
|
||||||
return;
|
return;
|
||||||
@@ -296,12 +295,12 @@ static char text[255];
|
|||||||
} /* got a row */
|
} /* got a row */
|
||||||
} else {
|
} else {
|
||||||
for (k=0;k<table->num_cols;k++) {
|
for (k=0;k<table->num_cols;k++) {
|
||||||
free(bound_values[k]);
|
g_free(bound_values[k]);
|
||||||
}
|
}
|
||||||
free(relationships[0]);
|
g_free(relationships[0]);
|
||||||
free(relationships[1]);
|
g_free(relationships[1]);
|
||||||
free(relationships[2]);
|
g_free(relationships[2]);
|
||||||
free(relationships[3]);
|
g_free(relationships[3]);
|
||||||
did_first = 0;
|
did_first = 0;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ MdbFile *f;
|
|||||||
fprintf(stderr, "Can't alloc filename\n");
|
fprintf(stderr, "Can't alloc filename\n");
|
||||||
free(f->filename);
|
free(f->filename);
|
||||||
free(f);
|
free(f);
|
||||||
if (mdb->backend_name) free(mdb->backend_name);
|
g_free(mdb->backend_name);
|
||||||
free(mdb);
|
free(mdb);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ mdb_close(MdbHandle *mdb)
|
|||||||
if (!mdb) return;
|
if (!mdb) return;
|
||||||
mdb_free_stats(mdb);
|
mdb_free_stats(mdb);
|
||||||
mdb_free_catalog(mdb);
|
mdb_free_catalog(mdb);
|
||||||
if (mdb->backend_name) free(mdb->backend_name);
|
g_free(mdb->backend_name);
|
||||||
|
|
||||||
if (mdb->f) {
|
if (mdb->f) {
|
||||||
if (mdb->f->refs > 1) {
|
if (mdb->f->refs > 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user