This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

malloc函数动态分配

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

  • 您好,

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

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

  • 我现在就是一个简单的测试程序,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 disallowed Category Typical functions in category Notes

    allowed String functions strcpy, strchr, ? 1

    allowed Memory-moving functions memcpy, memmove, memset, ... 2

    allowed Integer math support _divi, _divu, _remi, _remu, ... 2

    allowed Floating point support _addf, _subf, _mpyf, _divf, _addd, _subd, _mpyd, _divd, log10, cosh, ... 2, 3

    allowed Conversion functions atoi, ftoi, itof, ... 2

    disallowed Heap management functions malloc, free, realloc, alloc, ? 5

    disallowed I/O functions printf, open, read, write, ? 4

    disallowed misc. 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

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

    例程:

    www.ti.com.cn/.../sprc097

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

     

    这个要怎么解决呢