![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
I'm writing an application that will use either a single Berkeley database, or multiple databases, to simply access data. The database(s) will not be modified at all. What I'm having trouble with is that I'm trying to pass database handles to functions that will, among other things, open and close a database, retrieve elements from a database, etc. But I'm getting segmentation faults when actions are performed with these passed-in handles, and I'm not sure why. Below are my DB_Open() and DB_Close() functions (without the full checking of the "ret" variable to keep this post small). The DB_Open() seems to work fine, but when the DB_Close() attempts to close the dbHandle, the app crashes. Additionally, if I pull the contents of these functions out and place them in-line in the main() procedure, they work fine. Any insight would be greatly appreciated. Thank you. /************************************************** ******** ************************************************** ********/ int DB_Open(DB *dbHandle, char *DATABASE) { // Create the handle. int ret = db_create(&dbHandle, NULL, 0); if (ret==0) { // Open the database for read only. ret = dbHandle->open(dbHandle, NULL, DATABASE, NULL, DB_BTREE, DB_RDONLY, 0664); } return(0); } /************************************************** ******** ************************************************** ********/ int DB_Close(DB *dbHandle) { int ret = 0; ret = dbHandle->close(dbHandle, 0); return(0); } |
![]() |
| Thread Tools | |
| Display Modes | |
| |