Browse Source

+ simdb_record_bitmap()

master
Alex 'AdUser' Z 8 years ago
parent
commit
58289201a4
  1. 20
      src/database.c
  2. 13
      src/simdb.h

20
src/database.c

@ -317,6 +317,26 @@ simdb_record_del(simdb_t *db, int num) {
return num;
}
int
simdb_record_bitmap(simdb_t *db, int num, char **map, size_t *side) {
simdb_urec_t *rec;
int ret = 0;
assert(db != NULL);
if (num < 0 || map == NULL || side == NULL)
return SIMDB_ERR_USAGE;
if ((ret = simdb_read(db, num, 1, &rec)) <= 0)
return ret;
ret = simdb_bitmap_unpack(rec->bitmap, map);
*side = SIMDB_BITMAP_SIDE;
FREE(rec);
return ret;
}
int
simdb_records_count(simdb_t * const db) {
assert(db != NULL);

13
src/simdb.h

@ -160,6 +160,19 @@ int simdb_record_add(simdb_t *db, int num, const char *path, int flags);
*/
int simdb_record_del(simdb_t *db, int num);
/**
* @brief Get record bitmap
* @param db Database handle
* @param num Number of record to get bitmap
* @param bitmap Pointer to storage for bitmap (allocated)
* @param side Pointer to storage for bitmap side length
* @retval <0 on error
* @retval 0 if record not exists
* @retval >0 on success (this is size of allocated bitmap in bytes)
* @note Don't forget to free() bitmap on success
*/
int simdb_record_bitmap(simdb_t *db, int num, char **map, size_t *side);
/**
* @brief Get database capacity
*/

Loading…
Cancel
Save