From db57f1049d10d5e39e57e00a17334edce868dff7 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Fri, 30 Dec 2016 10:24:37 +1000 Subject: [PATCH] * use simdb_urec_t instead direct access by offsets --- src/simdb-query.c | 16 ++++++++++++---- src/simdb.h | 12 ------------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/simdb-query.c b/src/simdb-query.c index fea796f..0037ff3 100644 --- a/src/simdb-query.c +++ b/src/simdb-query.c @@ -17,6 +17,7 @@ #include "common.h" #include "bitmap.h" #include "simdb.h" +#include "record.h" #include #include @@ -121,6 +122,7 @@ int db_usage_slice(simdb_t *db, uint64_t offset, uint16_t limit) int rec_bitmap(simdb_t *db, uint64_t number) { simdb_rec_t rec; + simdb_urec_t *r; assert(db != NULL); memset(&rec, 0x0, sizeof(simdb_rec_t)); @@ -131,7 +133,8 @@ int rec_bitmap(simdb_t *db, uint64_t number) return 1; } - simdb_bitmap_print(&rec.data[REC_OFF_BM]); + r = (simdb_urec_t *) rec.data; + simdb_bitmap_print(r->bitmap); return 0; } @@ -139,27 +142,32 @@ int rec_bitmap(simdb_t *db, uint64_t number) int rec_diff(simdb_t *db, uint64_t a, uint64_t b, unsigned short int showmap) { simdb_rec_t rec; + simdb_urec_t *r; float diff = 0.0; unsigned char one[SIMDB_BITMAP_SIZE]; unsigned char two[SIMDB_BITMAP_SIZE]; unsigned char map[SIMDB_BITMAP_SIZE]; assert(db != NULL); - memset(&rec, 0x0, sizeof(simdb_rec_t)); + memset(&rec, 0x0, sizeof(rec)); + memset(one, 0x0, sizeof(one)); + memset(two, 0x0, sizeof(two)); rec.num = a; if (simdb_record_read(db, &rec) < 1) { fprintf(stderr, "record diff: first sample not exists\n"); return 1; } - memcpy(one, &rec.data[REC_OFF_BM], SIMDB_BITMAP_SIZE); + r = (simdb_urec_t *) rec.data; + memcpy(one, r->bitmap, sizeof(one)); rec.num = b; if (simdb_record_read(db, &rec) < 1) { fprintf(stderr, "record diff: second sample not exists\n"); return 1; } - memcpy(two, &rec.data[REC_OFF_BM], SIMDB_BITMAP_SIZE); + r = (simdb_urec_t *) rec.data; + memcpy(two, r->bitmap, sizeof(two)); if (showmap) { simdb_bitmap_diffmap(one, two, map); diff --git a/src/simdb.h b/src/simdb.h index 0a45add..72a7dee 100644 --- a/src/simdb.h +++ b/src/simdb.h @@ -39,18 +39,6 @@ /** opaque database handler */ typedef struct _simdb_t simdb_t; -/** - * @defgroup SIMDBRecOffsets Sample data parts offset in database record - * @{ */ -#define REC_OFF_RU 0 /**< record is used */ -#define REC_OFF_CR 1 /**< color level: red */ -#define REC_OFF_CG 2 /**< color level: green */ -#define REC_OFF_CB 3 /**< color level: blue */ -#define REC_OFF_IW 4 /**< image width */ -#define REC_OFF_IH 6 /**< image height */ -#define REC_OFF_BM 16 /**< image bitmap */ -/** @} */ - /** * database record */