From c3f902397fec8017551f27ffd292d18ebdda1c54 Mon Sep 17 00:00:00 2001 From: Alain Zscheile Date: Wed, 4 Jan 2023 09:59:14 +0100 Subject: [PATCH] lib/db: factor out zeros def --- lib/db.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/db.c b/lib/db.c index 32b9942..9e000e0 100644 --- a/lib/db.c +++ b/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;