DSPRelated.com
Forums

first malloc works, second not working

Started by Matt Weber August 25, 2005
Hello Everyone,

Well I have an interesting problem with my project. I have ported an Mp3
decoder to the SHARC and got it working on the 21065L, and 21060. The
project is written in C and has one assembly function. In order to create
enough storage space for my mp3 buffer I created a secondary heap which is
in external memory. One both the 065L and the 060 I managed to get the
decoder working perfectly. By modifying the *.ldf file I was able to fit the
large amount of program code I have into memory (with the excess not fitting
into internal memory being mapped into external memory segments).

Now that you know the situation, heres the problem. Initially I allocate
some memory into the external heap using malloc, for my mp3 buffer. That
works fine. Then when my decoder progresses into a few different functions,
another malloc is called, and this malloc doesn't seem to work. This is the
statement:

decoder->sync = malloc(sizeof(*decoder->sync));
if (decoder->sync == 0)
return -1;

This returns -1 every time. This is also the same code which works perfects
on the 060 and 065L. I tried to change where I allocate this memory, both in
the external and internal heap, which didnt help anything. I'm not sure why
this malloc isnt working considering I am allocating more than enough
memory. The mp3 I'm mapping into the heap is 2.44Kb and this has always fit
into previous heaps in the 065L and 060. Here are my external ldf segments: