Differences From Artifact [c3ebe65312]:
- File src/huffman_tree.m — part of check-in [d0ae3bfd6c] at 2020-10-25 23:33:09 on branch trunk — Add of_{malloc,calloc,realloc,free} (user: js, size: 2771) [annotate] [blame] [check-ins using]
To Artifact [f65a681bbc]:
- File
src/huffman_tree.m
— part of check-in
[3d8286feee]
at
2020-11-04 23:18:25
on branch trunk
— Remove of_free()
While it makes sense to wrap malloc and calloc to replace the error
checking with exceptions, it does not make sense to wrap free. (user: js, size: 2762) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
100 101 102 103 104 105 106 | for (uint16_t i = 0; i <= maxCode; i++) { uint8_t length = lengths[i]; if (length > 0) insertTree(tree, nextCode[length]++, length, i); } } @finally { | | | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | for (uint16_t i = 0; i <= maxCode; i++) { uint8_t length = lengths[i]; if (length > 0) insertTree(tree, nextCode[length]++, length, i); } } @finally { free(lengthCount); free(nextCode); } return tree; } struct of_huffman_tree * of_huffman_tree_construct_single(uint16_t value) |
︙ | ︙ | |||
124 125 126 127 128 129 130 | void of_huffman_tree_release(struct of_huffman_tree *tree) { for (uint_fast8_t i = 0; i < 2; i++) if OF_LIKELY (tree->leaves[i] != NULL) of_huffman_tree_release(tree->leaves[i]); | | | 124 125 126 127 128 129 130 131 132 | void of_huffman_tree_release(struct of_huffman_tree *tree) { for (uint_fast8_t i = 0; i < 2; i++) if OF_LIKELY (tree->leaves[i] != NULL) of_huffman_tree_release(tree->leaves[i]); free(tree); } |