TI中文支持网
TI专业的中文技术问题搜集分享网站

malloc函数动态分配

你好,怎么在DSP2812中动态分配空间地址,使用malloc函数程序总是跑飞。谢谢回答

Young Hu:

您好,

您分配的地址空间是多大的?应该是heap太小了。

Project -> Properties -> C/C++ Build -> Linker -> Basic Options -> Heap Size(-heap)

你好,怎么在DSP2812中动态分配空间地址,使用malloc函数程序总是跑飞。谢谢回答

xie xiaoyong:

回复 Young Hu:

我现在就是一个简单的测试程序,malloc两个字节的空间,-heap  0x1000,在device simulator下可以运行通过,

但是将程序连到f2812运行时就跑飞了,这是为什么?还有我还想请教的是在2812上可以用malloc函数吗?因为在ccs3.1

中help,输入malloc回车就出现下面一段话,求解释:

The following table summarizes the TI C-Language Run-time Support Library functions that may be referenced by eXpressDSP-compliant algorithms.

Allowed or disallowedCategoryTypical functions in categoryNotes

allowedString functionsstrcpy, strchr, ? 1

allowedMemory-moving functions memcpy, memmove, memset, …2

allowedInteger math support_divi, _divu, _remi, _remu, … 2

allowedFloating point support_addf, _subf, _mpyf, _divf, _addd, _subd, _mpyd, _divd, log10, cosh, … 2, 3

allowedConversion functionsatoi, ftoi, itof, …2

disallowedHeap management functions malloc, free, realloc, alloc, ? 5

disallowedI/O functionsprintf, open, read, write, ? 4

disallowedmisc. non-reentrant functions printf, sprintf, ctime, …5, 6

Notes:

1)Exceptions: strtok is not reentrant, and strdup allocates memory with malloc.

2)Some of these are issued by the compiler automatically for certain C operators.

3)The errno paradigm isn't reentrant. Thus, errno must not be used by eXpressDSP-compliant algorithms.

4)Algorithms are not allowed to perform I/O (except via DSP/BIOS APIs).

5)Algorithms must not allocate memory.

6)Algorithms must be reentrant and must, therefore, only reference reentrant functions.

See Also

Algorithm Standard rules topics

Use of DSP/BIOS API

你好,怎么在DSP2812中动态分配空间地址,使用malloc函数程序总是跑飞。谢谢回答

Forrest:

回复 xie xiaoyong:

2812上可以用malloc函数,既然在device simulator下可以运行通过,那我建议你用下面的例程试一下,在例程环境中使用malloc试试。

例程:

www.ti.com.cn/…/sprc097

你好,怎么在DSP2812中动态分配空间地址,使用malloc函数程序总是跑飞。谢谢回答

Ivy lin:

回复 Forrest:

请问楼上,我用的是F28335。使用malloc时老是出现warming:function declared implicitly

 

这个要怎么解决呢

赞(0)
未经允许不得转载:TI中文支持网 » malloc函数动态分配
分享到: 更多 (0)