diff options
-rw-r--r-- | firmware/export/system.h | 2 | ||||
-rw-r--r-- | firmware/font.c | 29 |
2 files changed, 15 insertions, 16 deletions
diff --git a/firmware/export/system.h b/firmware/export/system.h index cec47f1a71..aa079940d1 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h | |||
@@ -124,6 +124,8 @@ int get_cpu_boost_counter(void); | |||
124 | ptr = (typeof(ptr))tmp_ptr1; \ | 124 | ptr = (typeof(ptr))tmp_ptr1; \ |
125 | } | 125 | } |
126 | 126 | ||
127 | #define PTR_ADD(ptr, x) ((typeof(ptr))((char*)(ptr) + (x))) | ||
128 | #define PTR_SUB(ptr, x) ((typeof(ptr))((char*)(ptr) - (x))) | ||
127 | 129 | ||
128 | /* newer? SDL includes endian.h, So we ignore it */ | 130 | /* newer? SDL includes endian.h, So we ignore it */ |
129 | #if (CONFIG_PLATFORM & PLATFORM_HOSTED) || defined(__PCTOOL__) | 131 | #if (CONFIG_PLATFORM & PLATFORM_HOSTED) || defined(__PCTOOL__) |
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) | |||
88 | { | 88 | { |
89 | (void)handle; | 89 | (void)handle; |
90 | struct buflib_alloc_data *alloc = (struct buflib_alloc_data*)current; | 90 | struct buflib_alloc_data *alloc = (struct buflib_alloc_data*)current; |
91 | size_t diff = new - current; | 91 | ptrdiff_t diff = new - current; |
92 | 92 | ||
93 | if (alloc->handle_locked) | 93 | if (alloc->handle_locked) |
94 | return BUFLIB_CB_CANNOT_MOVE; | 94 | return BUFLIB_CB_CANNOT_MOVE; |
95 | 95 | ||
96 | if (alloc->font.bits) | 96 | #define UPDATE(x) if (x) { x = PTR_ADD(x, diff); } |
97 | alloc->font.bits += diff; | 97 | |
98 | if (alloc->font.offset) | 98 | UPDATE(alloc->font.bits); |
99 | alloc->font.offset += diff; | 99 | UPDATE(alloc->font.offset); |
100 | if (alloc->font.width) | 100 | UPDATE(alloc->font.width); |
101 | alloc->font.width += diff; | 101 | |
102 | 102 | UPDATE(alloc->font.buffer_start); | |
103 | alloc->font.buffer_start += diff; | 103 | UPDATE(alloc->font.buffer_end); |
104 | alloc->font.buffer_end += diff; | 104 | UPDATE(alloc->font.buffer_position); |
105 | alloc->font.buffer_position += diff; | 105 | |
106 | 106 | UPDATE(alloc->font.cache._index); | |
107 | if (alloc->font.cache._index) | 107 | UPDATE(alloc->font.cache._lru._base); |
108 | alloc->font.cache._index += diff; | ||
109 | if (alloc->font.cache._lru._base) | ||
110 | alloc->font.cache._lru._base += diff; | ||
111 | 108 | ||
112 | return BUFLIB_CB_OK; | 109 | return BUFLIB_CB_OK; |
113 | } | 110 | } |