Coldfire: malloc does not work properly

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Coldfire: malloc does not work properly

1,539 Views
jupe
Contributor I
Hi all,
maybe an experienced CodeWarrior user could help me.
 
My system mainly consists of Coldfire MCF5207 and 64-MBit SDRAM (size 0x800000 at 0x40000000).
The xmap-file of my project reports:
#>40060210          ___heap_addr (linker command file)
#>0079FD00          ___heap_size (linker command file)
This should be ok.

When I allocate memory I get the following results:
 malloc(0x800000): 0x00000000
This is ok because the requested memory is greater than ___heap_size.

But when I try to allocate a bit less memory several times I get more memory than I have:
 malloc(0x700000): 0x400e8990 .. ok
 malloc(0x700000): 0x407e8998 .. not ok
 malloc(0x700000): 0x40ee89a0 .. not ok
 malloc(0x700000): 0x415e89a8 .. not ok
 malloc(0x700000): 0x               .. system locks

Once allocated memory can be freed without problems.

I have the following files linked to my application:
fp_coldfire.o
C_4i_CF_StdABI_Runtime.a
C_4i_CF_StdABI_MSL.a
Is there anything I have missed (some kind of heap initialisation)?
Maybe somebody has a hint.

Best Regards
Peter

Message Edited by CrasyCat on 2007-04-13 01:31 PM

Labels (1)
0 Kudos
1 Reply

265 Views
pittbull
Contributor III
Hello,
I don't know exactly why this happens. It seems to be a bug in the heap manager because __head_addr and __heap_size are properly set. Anyway, there are many memory allocators around the net, for example this one: http://www.keil.com/download/docs/18.asp
0 Kudos