Hi there,
I am having a minor issue when trying to malloc() memory for a list of database
connections. I need to keep open a large number of database files and run
queries against them. The application is running on Linux and is a
synchronuous, single threaded application.
In order to keep all these database connections open, I defined an array
(simple list) but when I am trying to allocate memory for sqlite3 type I get an
error complaining about sizeof(sqlite3). I can't keep defining variables for
each database open because there might be too many and I don't know in advance
the database name, just its structure.
Here is what I am doing:
struct db_cache_type
{
sqlite3 *db; /* database file pointer */
char *key; /* key identifies the database that was opened */
int mode; /* database open mode */
};
struct db_cache_type **db_cache_list; /* list of database connections */
int db_cache_count; /* number of databases in pool */
/* allocate memory for array */
db_cache_list = (struct db_cache_type **)malloc(1 * sizeof(struct db_cache_type
*));
/* ______________________________ ERROR ON NEXT LINE at sizeof()
___________________________*/
db_cache_list[i] = (struct sqlite3 *)malloc(db_cache_count * sizeof(struct
sqlite3));
db_cache_list[i]->db = db;
Any help on how to create an array of sqlite3 database connections would be
greatly appreciated.
Thanks in advance.
David
____________________________________________________________________________________
Get easy, one-click access to your favorites.
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs