Lossless data compression in C without dynamic memory allocation

浪子不回头ぞ 提交于 2019-12-11 02:27:36

问题


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:


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.



来源:https://stackoverflow.com/questions/19263121/lossless-data-compression-in-c-without-dynamic-memory-allocation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!