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.

LAUNCHXL-F28379D: How to allocate memory on the heap with malloc()?

Part Number: LAUNCHXL-F28379D

Hello experts,

as you can see in the source code, I am trying to allocate a memory area within the heap.

However, it did not work. The malloc() function always returns with a null pointer (p_data = NULL).

I tried all combinations of the four settings (see picture below). But it did not help.

Can you give me some hints to solve the problem?

Thanks in advance - Bui

  • Hello Bui,

    To clarify, the p_data is set to null before the "p_data = NULL" line is reached (i.e. the conditional is false), correct? What does the p_data value show as in the Expressions window of a debug session?

    I'm also a little confused what you're trying to indicate by including a screenshot of the Project Properties, you're deleting the value used for the heap size?

    Best regards,

    Omer Amir

  • Hello Omer,

    thank you very much for the answer!
    Because I did not manage to allocate the memory on the heap, I then varied all the settings to find the reason. In the meantime I found the reason. It was a wrong setting somewhere else. This was a pretty stupid mistake of mine.
    Now I can allocate the memory on the heap and my test program works also with the allocated heap. But I still get the warning

    Do you maybe have an explanation for me? By the way, is there any documentation about warnings from compiler and linker? I googled for #10473-D but without success.


    Have a nice weekend - Bui

  • Hello Bui,

    I believe this warning relates to the bottom half of your screenshot, which I pointed out earlier:

    You set the heap size to 0, the warning states that the minimum size needs to be 503 (I believe the Project Properties uses a hex value, which is why 200 was set before by default).

    Best regards,

    Omer Amir

  • Hello Omer,

    thanks for the feedback!
    No, it is not the reason for the compiler warning. I have checked the setting of linker. Everything is correct. However, the warning is still there. At the moment it doesn't bother me, because allocating memory works and using memory also works. Once again the question. Where can I get the explanation about the warning/error of compiler/linker?

    Thanks in advance - Bui

  • I need to reproduce the linker warning diagnostic.  I think I can do it just by looking at the build log of your project.  Please rebuild the entire project.  One way to do that is to right-click on the name of the project and select Rebuild Project.  Then save the contents of the Console (not Problems) view to a text file.  Use the icon named Copy Build Log.  When you name the log file, be sure to use the file extension .txt.  Please attach that text file to your next post.

    Thanks and regards,

    -George

  • Good morning Mock,

    thanks for the feedback.
    I tried for a long time and found out that if heap is on the .bss:taskStackSection, the warning does not come anymore.

    Have a nice day - Bui