summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-30 02:29:35 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-09-19 15:09:51 -0400
commitb12427741a66d7af983f0efd85a447cbdd6afbb9 (patch)
tree03d02345339e7f0aa48d6aa1cecc046a708d668e /apps/plugins
parentfdde6bb5a7de9d1b013dd8da48d6a603b482f1f6 (diff)
downloadrockbox-b12427741a66d7af983f0efd85a447cbdd6afbb9.tar.gz
rockbox-b12427741a66d7af983f0efd85a447cbdd6afbb9.zip
buflib: clean up and refactor to improve maintainability
Buflib is written with a lot of hardcoded offsets to header fields, arbitrary pointer arithmetic, and similar but not quite duplicated code, making maintenance a nightmare. Most of the pointer arithmetic involving header fields is replaced by indexing from two well-defined pointers, the block start and end pointers. The start pointer points to the first header field, and he end pointer is one past the end of the header. Hardcoded field indices are replaced by two enums. Forward indices (fidx_XXX) are used to access fields from a block start pointer and negated backward indices (-bidx_XXX) are used to index from a block end pointer. There is no overlap between the indices because of the variable length name field in the middle of the header. The length of the fixed fields in the block header is now a #define'd constant rather than being open coded. There is now a function to acquire the block end pointer from the user data pointer (ie. the pointer stored in the handle table). The old code was not consistent in this; some functions would handle a non-aligned user pointer, which may occur as a result of shrinking, while other uses just assumed the user pointer was aligned. Block CRC calculations have also been factored out to a function that accepts block start and end pointers. Change-Id: I6a7e8a8c58aec6c6eaf0e5021400032d8e5f841e
Diffstat (limited to 'apps/plugins')
0 files changed, 0 insertions, 0 deletions