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-05 14:51:52 +0100 |
commit | 86786f4cc6800fa6c6282f8a87e2defacebeb94d (patch) | |
tree | d4654c97e951cfab09886135e324df143bf90353 | |
parent | d8e8d3cceef907f798276014ebdfed7c370fb866 (diff) | |
download | libnsgif-86786f4cc6800fa6c6282f8a87e2defacebeb94d.tar.gz libnsgif-86786f4cc6800fa6c6282f8a87e2defacebeb94d.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_DICTIONARY_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_DICTIONARY_ENTRY_MAX]; /** LZW decode dictionary. Generated during decode. */ - struct lzw_dictionary_entry table[1 << LZW_CODE_MAX]; + struct lzw_dictionary_entry table[LZW_DICTIONARY_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_DICTIONARY_ENTRY_MAX) { struct lzw_dictionary_entry *entry = table + current_entry; entry->last_value = last_value; entry->first_value = ctx->previous_code_first; |