*/
bool get_all_items(GArray * items){
g_array_set_size(items, 0);
+
if ( !m_db )
return false;
/* Get a cursor */
m_db->cursor(m_db, NULL, &cursorp, 0);
+ if (NULL == cursorp)
+ return false;
+
/* Initialize our DBTs. */
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
if ( ret != DB_NOTFOUND ){
fprintf(stderr, "training db error, exit!");
+
+ if (cursorp != NULL)
+ cursorp->c_close(cursorp);
+
exit(EIO);
}
ret = db_create(&tmp_db, NULL, 0);
assert(ret == 0);
+ if (NULL == tmp_db)
+ return false;
+
ret = tmp_db->open(tmp_db, NULL, dbfile, NULL,
DB_HASH, DB_RDONLY, 0600);
if ( ret != 0 )
DBC * cursorp = NULL;
DBT key, data;
+
/* Get a cursor */
tmp_db->cursor(tmp_db, NULL, &cursorp, 0);
+ if (NULL == cursorp)
+ return false;
+
/* Initialize our DBTs. */
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
ret = db_create(&tmp_db, NULL, 0);
assert(ret == 0);
+ if (NULL == tmp_db)
+ return false;
+
ret = tmp_db->open(tmp_db, NULL, dbfile, NULL,
DB_HASH, DB_CREATE, 0600);
if ( ret != 0 )
/* Get a cursor */
m_db->cursor(m_db, NULL, &cursorp, 0);
+ if (NULL == cursorp)
+ return false;
+
/* Initialize our DBTs. */
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
DBT key, data;
int ret;
/* Get a cursor */
- m_db->cursor(m_db, NULL, &cursorp, 0);
+ m_db->cursor(m_db, NULL, &cursorp, 0);
+
+ if (NULL == cursorp)
+ return false;
/* Initialize our DBTs. */
memset(&key, 0, sizeof(DBT));