
www.Usenet.com
| <-- __Chronological__ --> | <-- __Thread__ --> |
"Sarge" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Your problem is simple - you are calling db_create() with the
> address of a stack argument. So the DB* that you pass in to
> the function DB_Open() is not changed. In other words,
> change it to something like this:
>
> int DB_Open(DB **dbHandle, char *DATABASE)
> {
> DB *db;
>
> // Create the handle.
> int ret = db_create(&db, NULL, 0);
>
> if (ret==0) {
> // Open the database for read only.
> ret = db->open(db, NULL, DATABASE, NULL,
> DB_BTREE, DB_RDONLY, 0664);
> }
> *dbHandle = db;
> return(0);
> }
>
> Hope this helps,
> --Sarge
Sweet! It _did_ help, thank you very much. I'm new to this and
learning as I go. Thanks again.
-Jim
>
>
> "Anon" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > 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);
> > }
| <-- __Chronological__ --> | <-- __Thread__ --> |