cancel
Showing results for 
Search instead for 
Did you mean: 

memory allocation

sarangbhalerao
Associate II
Posted on February 10, 2006 at 12:31

memory allocation

3 REPLIES 3
sarangbhalerao
Associate II
Posted on February 09, 2006 at 14:12

Hello,

Somehow memory allocation functions calloc, malloc, free are not working for me. Anybody has working code...?

I will post what I am doing and can anybody figure out what am I doing wrong...?

typedef struct BT_INFO{

//unsigned int ..

//unsigned ...

//etc

}BT_INFO;

typedef unsigned int HANDLE;

HANDLE BT_Init(void){

BT_INFO *BT_Info;

BT_Info = calloc (sizeof(BT_INFO),sizeof(unsigned char));

if(BT_Info){

return HANDLE)BT_Info;

}else{

return 0;

}

}

It always returns 0.

This code is working on 2 other compilers (non ARM) and I couldn't figure out whats wrong on IAR. Code compiles with 0 errors and 0 warnings on IAR.

I have declared the heap size as 8000 in stacks and heap section of options.

I am using IAR STR711F kit.

Thanks in advance,

Ranga

sarangbhalerao
Associate II
Posted on February 10, 2006 at 10:27

Thanks a lot. But it doesn't work for me... :-[

I use IAR Kickstart version and I am wondering that this is a problem with IAR 4.30A KICKSTART version. They limit the functionality of KICKSTART version.

Any comments...?

Thanks,

Ranga

sarangbhalerao
Associate II
Posted on February 10, 2006 at 12:31

Finally figured out the problem..whoooof..!!! :-]

Anyways, it's the linker file I was using.

I changed it and it started working. I considered that previous heap was initialised for 8000 bytes and I was wrong. So no more assumptions now... 😉

//*************************************************************************

// Stack and heap segments.

//*************************************************************************

-D_CSTACK_SIZE=400

// -D_SVC_STACK_SIZE=10

-D_IRQ_STACK_SIZE=500

//-D_HEAP_SIZE=4

-D_HEAP_SIZE=1000

-Z(DATA)CSTACK+_CSTACK_SIZE=RAMSTART-RAMEND

// -Z(DATA)SVC_STACK+_SVC_STACK_SIZE=RAMSTART-RAMEND

-Z(DATA)IRQ_STACK+_IRQ_STACK_SIZE,HEAP+_HEAP_SIZE=RAMSTART-RAMEND

thanks,

Ranga