(database_info.c) Add some error handling
This commit is contained in:
parent
8bde46deb9
commit
99ea729d1c
2 changed files with 14 additions and 2 deletions
|
@ -227,11 +227,20 @@ static int database_cursor_open(libretrodb_t *db,
|
||||||
strlen(query), &error);
|
strlen(query), &error);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
return -1;
|
goto error;
|
||||||
if ((libretrodb_cursor_open(db, cur, q)) != 0)
|
if ((libretrodb_cursor_open(db, cur, q)) != 0)
|
||||||
return -1;
|
goto error;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (query)
|
||||||
|
libretrodb_query_free(q);
|
||||||
|
query = NULL;
|
||||||
|
libretrodb_close(db);
|
||||||
|
db = NULL;
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int database_cursor_close(libretrodb_t *db, libretrodb_cursor_t *cur)
|
static int database_cursor_close(libretrodb_t *db, libretrodb_cursor_t *cur)
|
||||||
|
|
|
@ -141,6 +141,9 @@ static void libretrodb_write_index_header(int fd, libretrodb_index_t * idx)
|
||||||
|
|
||||||
void libretrodb_close(libretrodb_t *db)
|
void libretrodb_close(libretrodb_t *db)
|
||||||
{
|
{
|
||||||
|
if (!db)
|
||||||
|
return;
|
||||||
|
|
||||||
close(db->fd);
|
close(db->fd);
|
||||||
db->fd = -1;
|
db->fd = -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue