2
votes

I'm currently trying to implement a lossless data compression algorithm for a project I'm working on. The goal is to compress a fixed size list of floating point values. The code has to be written in C and can NOT use dynamic memory allocation. This hurts me greatly since most, if not all, lossless algorithms require some dynamic allocation.

Two of the main algorithms I've been looking into are Huffman's and Arithmetic. Would this task be possible without dynamic memory allocation? Are there any approaches or ideas you guys have? If you think it's not possible, please let me know why :-)

Any help/suggestions will help!

1

1 Answers

3
votes

I don't see any reason either should need dynamic memory allocation. The size of the working data set is bounded, so just use an array of that size (preferably with automatic storage duration so that you don't make the code gratuitously non-reentrant, but static storage duration would also work) and do all your work in there.