Browse Source

* change imdb_usage_map()

master
Alex 'AdUser' Z 10 years ago
parent
commit
c5fceaf78b
  1. 11
      src/database.c
  2. 2
      src/database.h
  3. 7
      src/util.c

11
src/database.c

@ -334,14 +334,19 @@ imdb_search(imdb_t * const db,
uint64_t uint64_t
imdb_usage_map(imdb_t * const db, imdb_usage_map(imdb_t * const db,
char * const map) { char ** const map) {
const int blk_size = 4096; const int blk_size = 4096;
imdb_block_t blk; imdb_block_t blk;
uint64_t records;
unsigned char *r; /* mnemonics : block, record */ unsigned char *r; /* mnemonics : block, record */
char *m = map; /* mnemonics : map */ char *m = NULL; /* mnemonics : map */
memset(&blk, 0x0, sizeof(imdb_block_t)); memset(&blk, 0x0, sizeof(imdb_block_t));
records = imdb_records_count(db);
CALLOC(*map, records + 1, sizeof(char));
m = *map;
blk.start = 1; blk.start = 1;
blk.records = blk_size; blk.records = blk_size;
@ -354,5 +359,5 @@ imdb_usage_map(imdb_t * const db,
} }
FREE(blk.data); FREE(blk.data);
return blk.start + blk.records; return records;
} }

2
src/database.h

@ -114,5 +114,5 @@ imdb_records_count(imdb_t * const db);
*/ */
uint64_t uint64_t
imdb_usage_map(imdb_t * const db, imdb_usage_map(imdb_t * const db,
char * const map); char ** const map);
#endif #endif

7
src/util.c

@ -76,11 +76,8 @@ int db_usage_map(imdb_t *db, unsigned short int cols)
memset(row, 0x0, sizeof(char) * 256); memset(row, 0x0, sizeof(char) * 256);
records = imdb_records_count(db); if ((records = imdb_usage_map(db, &map)) == 0) {
CALLOC(map, records + 1, sizeof(char)); printf("Can't get database usage map\n");
if ((records = imdb_usage_map(db, map)) == 0) {
printf("Cant get database usage map\n");
FREE(map); FREE(map);
exit(1); exit(1);
} }

Loading…
Cancel
Save