summaryrefslogtreecommitdiffstats
path: root/firmware/font.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/font.c')
-rw-r--r--firmware/font.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/firmware/font.c b/firmware/font.c
index 0546061a15..8cd9be1ad5 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -88,26 +88,23 @@ static int buflibmove_callback(int handle, void* current, void* new)
{
(void)handle;
struct buflib_alloc_data *alloc = (struct buflib_alloc_data*)current;
- size_t diff = new - current;
+ ptrdiff_t diff = new - current;
if (alloc->handle_locked)
return BUFLIB_CB_CANNOT_MOVE;
- if (alloc->font.bits)
- alloc->font.bits += diff;
- if (alloc->font.offset)
- alloc->font.offset += diff;
- if (alloc->font.width)
- alloc->font.width += diff;
-
- alloc->font.buffer_start += diff;
- alloc->font.buffer_end += diff;
- alloc->font.buffer_position += diff;
-
- if (alloc->font.cache._index)
- alloc->font.cache._index += diff;
- if (alloc->font.cache._lru._base)
- alloc->font.cache._lru._base += diff;
+#define UPDATE(x) if (x) { x = PTR_ADD(x, diff); }
+
+ UPDATE(alloc->font.bits);
+ UPDATE(alloc->font.offset);
+ UPDATE(alloc->font.width);
+
+ UPDATE(alloc->font.buffer_start);
+ UPDATE(alloc->font.buffer_end);
+ UPDATE(alloc->font.buffer_position);
+
+ UPDATE(alloc->font.cache._index);
+ UPDATE(alloc->font.cache._lru._base);
return BUFLIB_CB_OK;
}