summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2021-08-13 23:58:56 +0100
committerJohn-Mark Bell <jmb@netsurf-browser.org>2021-08-14 01:33:23 +0100
commitc69d7fee4ef1820296cb1c0db072e01cf6970ce1 (patch)
tree0b4eb8084019ebe7311cbeea3771b8a084de3245
parent158483bc75ac79cb2699d92e30f30aeefefe56ca (diff)
downloadlibrufl-c69d7fee4ef1820296cb1c0db072e01cf6970ce1.tar.gz
librufl-c69d7fee4ef1820296cb1c0db072e01cf6970ce1.tar.bz2
Fix shrinkwrap moving blocks
All blocks subsequent to a full one get moved up and all their indices need rewriting.
-rw-r--r--src/rufl_init.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/rufl_init.c b/src/rufl_init.c
index f49ceff..29ef415 100644
--- a/src/rufl_init.c
+++ b/src/rufl_init.c
@@ -472,31 +472,26 @@ static void rufl_init_shrinkwrap_plane(struct rufl_character_set *charset)
for (byte = 0; byte != 32; byte++)
bit &= charset->block[block][byte];
- if (bit == 0xff) {
- /* Block is full */
-
- /* Find a block whose index is after this one.
- * If such a block exists, move its data into
- * this block, as this block's bitmap is now free
- */
- for (byte = 0; byte != 256; byte++) {
- if (charset->index[byte] < BLOCK_EMPTY &&
- charset->index[byte] > block) {
- break;
- }
- }
- if (byte != 256) {
- memcpy(charset->block[block],
- charset->block[
- charset->index[byte]],
- 32);
- charset->index[byte] = block;
- }
- /* Now mark this block as full */
- charset->index[u] = BLOCK_FULL;
- last_used--;
+ if (bit != 0xff)
+ continue;
+
+ /* Block is full */
+
+ /* Move subsequent blocks up and rewrite their indices */
+ memmove(charset->block[block],
+ charset->block[block+1],
+ (254-(block+1)) * 32);
+ for (byte = 0; byte != 256; byte++) {
+ if (charset->index[byte] < BLOCK_EMPTY &&
+ charset->index[byte] > block) {
+ charset->index[byte]--;
+ }
}
+
+ /* Now mark this block as full */
+ charset->index[u] = BLOCK_FULL;
+ last_used--;
}
/* Fill in this plane's size now we know it */