From c5fceaf78bf3cd7579ea3f83825b478566faed61 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sun, 22 Mar 2015 01:52:21 +1000 Subject: [PATCH] * change imdb_usage_map() --- src/database.c | 11 ++++++++--- src/database.h | 2 +- src/util.c | 7 ++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/database.c b/src/database.c index 06931cc..c03f708 100644 --- a/src/database.c +++ b/src/database.c @@ -334,14 +334,19 @@ imdb_search(imdb_t * const db, uint64_t imdb_usage_map(imdb_t * const db, - char * const map) { + char ** const map) { const int blk_size = 4096; imdb_block_t blk; + uint64_t records; unsigned char *r; /* mnemonics : block, record */ - char *m = map; /* mnemonics : map */ + char *m = NULL; /* mnemonics : map */ memset(&blk, 0x0, sizeof(imdb_block_t)); + records = imdb_records_count(db); + CALLOC(*map, records + 1, sizeof(char)); + + m = *map; blk.start = 1; blk.records = blk_size; @@ -354,5 +359,5 @@ imdb_usage_map(imdb_t * const db, } FREE(blk.data); - return blk.start + blk.records; + return records; } diff --git a/src/database.h b/src/database.h index 0e7cb0a..719125a 100644 --- a/src/database.h +++ b/src/database.h @@ -114,5 +114,5 @@ imdb_records_count(imdb_t * const db); */ uint64_t imdb_usage_map(imdb_t * const db, - char * const map); + char ** const map); #endif diff --git a/src/util.c b/src/util.c index 597abb7..688bb8b 100644 --- a/src/util.c +++ b/src/util.c @@ -76,11 +76,8 @@ int db_usage_map(imdb_t *db, unsigned short int cols) memset(row, 0x0, sizeof(char) * 256); - records = imdb_records_count(db); - CALLOC(map, records + 1, sizeof(char)); - - if ((records = imdb_usage_map(db, map)) == 0) { - printf("Cant get database usage map\n"); + if ((records = imdb_usage_map(db, &map)) == 0) { + printf("Can't get database usage map\n"); FREE(map); exit(1); }