Browse Source

* change simdb_usage_*() : use just 0x0 and 0x1

master
Alex 'AdUser' Z 8 years ago
parent
commit
e938df873f
  1. 4
      src/database.c
  2. 10
      src/simdb-query.c

4
src/database.c

@ -513,7 +513,7 @@ simdb_usage_map(simdb_t * const db, char ** const map) {
break;
r = data;
for (int i = 0; i < ret; i++, m++, r++) {
*m = (r->used == 0xFF) ? CHAR_USED : CHAR_NONE;
*m = (r->used == 0xFF) ? 0x1 : 0x0;
}
FREE(data);
}
@ -544,7 +544,7 @@ simdb_usage_slice(simdb_t * const db, char ** const map, int offset, int limit)
r = data;
for (int i = 0; i < limit; i++, m++, r++) {
*m = (r->used == 0xFF) ? CHAR_USED : CHAR_NONE;
*m = (r->used == 0xFF) ? 0x1 : 0x0;
}
FREE(data);

10
src/simdb-query.c

@ -23,6 +23,9 @@
#include <unistd.h>
#include <getopt.h>
#define CHAR_USED '@'
#define CHAR_FREE '-'
void usage(int exitcode) {
fprintf(stderr,
"Usage: simdb-query <opts>\n"
@ -85,8 +88,11 @@ int db_usage_map(simdb_t *db, unsigned short int cols)
return 1;
}
for (uint16_t i = 0; i < records; i++)
map[i] = map[i] ? CHAR_USED : CHAR_FREE;
if (cols == 0) {
putchar(CHAR_NONE); /* zero */
putchar(CHAR_FREE); /* zero */
puts(map);
FREE(map);
return 0;
@ -111,6 +117,8 @@ int db_usage_slice(simdb_t *db, uint64_t offset, uint16_t limit)
char *map = NULL;
limit = simdb_usage_slice(db, &map, offset, limit);
for (uint16_t i = 0; i < limit; i++)
map[i] = map[i] ? CHAR_USED : CHAR_FREE;
puts(map);
FREE(map);

Loading…
Cancel
Save