没有动态内存分配的C中无损数据压缩 [英] Lossless data compression in C without dynamic memory allocation

查看:109
本文介绍了没有动态内存分配的C中无损数据压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试为我正在研究的项目实施无损数据压缩算法。目标是压缩固定大小的浮点值列表。该代码必须用C编写,并且不能使用动态内存分配。因为大多数(即使不是全部)无损算法都需要进行动态分配,这对我造成了极大的伤害。

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!

推荐答案

我看不到任何理由都需要动态内存分配。工作数据集的大小是有界的,因此只需使用该大小的数组(最好使用自动存储持续时间,这样就不会使代码不必要地重入,但是静态存储持续时间也可以工作)并执行所有操作在那儿工作。

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.

这篇关于没有动态内存分配的C中无损数据压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆