DSPRelated.com
Forums

MEM_calloc and it's return value

Started by NOR RIZUAN MAT NOOR May 23, 2006
Hi everybody!

I have a few questions about MEM_alloc (again!). :D

I have write one simple program to allocate memory to store pixel coordinate in memory. I used DSP/BIOS, and my heap size is 0x00080000 in SDRAM with heap identifier label SEG0. I have used MEM_calloc as below :

struct pixel * create_pixel(int m, int n)
{
struct pixel * temp = (struct pixel*)MEM_calloc(SEG0, 1*sizeof(struct pixel), 0);

if(temp==MEM_ILLEGAL)
{
LOG_printf(&trace, "Memory allocation for pixel failed");
exit(0);
}
else
{
temp->m = m;
temp->n = n;
temp->next = NULL;
}

return temp;
}

And I call the function above by using :

struct pixel * point;

SeedXA1[12][59];
SeedYA1[67][40];
point = create_pixel(SeedX, SeedY);

And the pixel properties is :

/* structure for a pixel */
struct pixel
{
int m;
int n;
struct pixel *next;
};

The code run successfully since the return value (temp) is equal to 0x8007FFF0 which is my SDRAM location.

Then, I have included this code into my big program to extract certain features from the image taken, the program halted at :

00014C60 _MEM_valloc:
00014C60 753983A3 [!B2] MVC.S2 DP,ACR
00014C64 3FA1055A .word 0x3fa1055a
00014C68 1E79116F .word 0x1e79116f :HALTED HERE
00014C6C 3FA79C12 || [!B0] B.S2 0xFFFE8940 :AND HERE

When I check the return value (temp), it gives 1. What does this mean ? Is this because of block align properties that I set to 0 ?

Please, I really hope that somebody can help me pointing me out from this problem. Thanks in advance.

Best regards,
azreque