diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2021-03-31 19:12:38 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2021-04-06 09:03:19 +0100 |
commit | 29f3d0fb22f9cdbd603e9561c9c8e000a2d6d5ef (patch) | |
tree | 16f16d031900c0a6229b92d775039c73c6dde853 | |
parent | d8e8d3cceef907f798276014ebdfed7c370fb866 (diff) | |
download | libnsgif-29f3d0fb22f9cdbd603e9561c9c8e000a2d6d5ef.tar.gz libnsgif-29f3d0fb22f9cdbd603e9561c9c8e000a2d6d5ef.tar.bz2 |
lzw: Create #define for number of dictionary entry slots.
-rw-r--r-- | src/lzw.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -21,6 +21,8 @@ * Decoder for GIF LZW data. */ +/** Maximum number of dictionary entries. */ +#define LZW_TABLE_ENTRY_MAX (1u << LZW_CODE_MAX) /** * Context for reading LZW data. @@ -79,10 +81,10 @@ struct lzw_ctx { uint32_t current_entry; /**< Next position in table to fill. */ /** Output value stack. */ - uint8_t stack_base[1 << LZW_CODE_MAX]; + uint8_t stack_base[LZW_TABLE_ENTRY_MAX]; /** LZW decode dictionary. Generated during decode. */ - struct lzw_dictionary_entry table[1 << LZW_CODE_MAX]; + struct lzw_dictionary_entry table[LZW_TABLE_ENTRY_MAX]; }; @@ -342,7 +344,7 @@ lzw_result lzw_decode(struct lzw_ctx *ctx, } /* Add to the dictionary, only if there's space */ - if (current_entry < (1 << LZW_CODE_MAX)) { + if (current_entry < LZW_TABLE_ENTRY_MAX) { struct lzw_dictionary_entry *entry = table + current_entry; entry->last_value = last_value; entry->first_value = ctx->previous_code_first; |