Ejemplo n.º 1
0
bool DBPrivAdvanceCursor(DBCursorPriv *cursor, void **key, int *key_size,
                     void **value, int *value_size)
{
    *key = tchdbgetnext3(cursor->db->hdb,
                         cursor->current_key, cursor->current_key_size,
                         key_size, (const char **)value, value_size);

    /*
     * If there is pending delete on the key, apply it
     */
    if (cursor->pending_delete)
    {
        Delete(cursor->db->hdb, cursor->current_key, cursor->current_key_size);
    }

    /* This will free the value as well: tchdbgetnext3 returns single allocated
     * chunk of memory */

    free(cursor->current_key);

    cursor->current_key = *key;
    cursor->current_key_size = *key_size;
    cursor->pending_delete = false;

    return *key != NULL;
}
Ejemplo n.º 2
0
char *tc_get_next(TCHDB *hdb, const char *path, char *last_key, 
					int last_key_len, int *current_key_len, 
					const char **fetched_data, int *fetched_data_len)
{
	if (hdb == NULL)
		return NULL;

	char *current_key = NULL;

	TC_RETRY_LOOP(hdb, path, ( 
					current_key = tchdbgetnext3(hdb, 
					last_key, last_key_len, 
					current_key_len, fetched_data, 
					fetched_data_len)) != NULL, 
			break);

	return current_key;
}