lib/db: factor out zeros def
This commit is contained in:
parent
21c7228038
commit
c3f902397f
5
lib/db.c
5
lib/db.c
|
@ -13,6 +13,8 @@ typedef struct {
|
|||
int fd;
|
||||
} y16t_db_actx_t;
|
||||
|
||||
static const uint8_t zeros[44] = {0};
|
||||
|
||||
__attribute__((pure)) static off_t
|
||||
y16t_db_offstr(const uint32_t offset) { return ((off_t)offset) << 12; }
|
||||
|
||||
|
@ -53,7 +55,6 @@ static int y16t_db_intern_pgsearch(
|
|||
uint32_t *i_
|
||||
) {
|
||||
uint8_t buf[4096] = {0};
|
||||
const uint8_t zeros[44] = {0};
|
||||
ssize_t tmp = y16t_pread_all(fd, buf, sizeof(buf), start_offset);
|
||||
if(tmp < 0) return (int)tmp;
|
||||
|
||||
|
@ -174,7 +175,6 @@ static int y16t_db_foreach_x3(uint8_t x1, uint32_t offset, void *context_)
|
|||
|
||||
// sequential data, read complete page
|
||||
uint8_t buf[4096] = {0};
|
||||
const uint8_t zeros[44] = {0};
|
||||
const off_t start_offset = y16t_db_offstr(offset);
|
||||
ssize_t tmp = y16t_pread_all(context->db, buf, sizeof(buf), start_offset);
|
||||
if(tmp < 0) return (int)tmp;
|
||||
|
@ -203,7 +203,6 @@ static int y16t_db_foreach_y3(uint8_t y1, uint32_t offset, void *context_)
|
|||
|
||||
// sequential data, read complete page
|
||||
uint8_t buf[4096] = {0};
|
||||
const uint8_t zeros[44] = {0};
|
||||
const off_t start_offset = y16t_db_offstr(offset);
|
||||
ssize_t tmp = y16t_pread_all(context->db, buf, sizeof(buf), start_offset);
|
||||
if(tmp < 0) return (int)tmp;
|
||||
|
|
Loading…
Reference in a new issue