handle->close() ; error "SEGMENTATION FAULT" -
11-21-2005
, 06:10 AM
Hello,
I am writting here because I would like to know why my code cause
an "segmentation fault" with berkeley db library.
Creating handle works well but closing it.
#include <db.h>
#include <stdio.h>
DB *h_journal;
/****************************************
*****************************************
** CREATE handle **
** **
*****************************************
*****************************************/
int create_handle(DB *db_handle, u_int32_t flags)
{
int ret;
ret = db_create(&db_handle, NULL, 0);
if (ret != 0)
{
db_handle->close(db_handle, 0);
return (ret);
}
else
{
ret = db_handle->set_flags(db_handle, flags);
if (ret != 0) return (ret);
}
return (0);
}
/****************************************
*****************************************
** CLOSE a handle **
** **
*****************************************
*****************************************/
int close_handle(DB *db_handle)
{
db_handle->close(db_handle, 0);
}
void main(void)
{
if ( create_handle(h_journal, DB_DUPSORT) )
printf("\n--Error creating handle\n"); // This line works well
close_handle(h_journal); // This line makes an "SEGMENTATION FAULT"
error
} |