DSPRelated.com
Forums

Example on MEM_alloc OR MEM_calloc OR MEM_valloc

Started by norr...@yahoo.co.uk May 17, 2006
Hi guys,
Really appreciate this forum since the first time I join this forum :)

We always found in this forum about the issue of allocating memory dynamically. Can anyone give some examples on using MEM_alloc or MEM_calloc or MEM_valloc. Below is one example that I took from other discussion from this forum.

while(1)
{
p1 = (char*)MEM_alloc(heap1, 100, 8);
p2 = (char*)MEM_alloc(heap2, 100, 8);

MEM_free(heap1,p1,100);
MEM_free(heap2,p2,100);
}

Thanks, and I understand the syntax. But, can anyone give some example to assign value to this 'new' variable. I have tried like below :

while(1)
{
p1 = (char*)MEM_alloc(heap1, 100, 8);
p2 = (char*)MEM_alloc(heap2, 100, 8);

p1#; //I want to assigned new value to p1

MEM_free(heap1,p1,100);
MEM_free(heap2,p2,100);
}

but got error:
a value of type
Hi norrizuan

Look at the info on MEM_calloc that you can find in the help function
of CCS. It returns a pointer to where it's giving you the memory you
asked for. It's not a value that you should change, it's where you
get to stuff your data.

Al
--- In c..., norrizuan@... wrote:
>
> Hi guys,
> Really appreciate this forum since the first time I join this forum :)
>
> We always found in this forum about the issue of allocating memory
dynamically. Can anyone give some examples on using MEM_alloc or
MEM_calloc or MEM_valloc. Below is one example that I took from other
discussion from this forum.
>
> while(1)
> {
> p1 = (char*)MEM_alloc(heap1, 100, 8);
> p2 = (char*)MEM_alloc(heap2, 100, 8);
>
> MEM_free(heap1,p1,100);
> MEM_free(heap2,p2,100);
> }
>
> Thanks, and I understand the syntax. But, can anyone give some
example to assign value to this 'new' variable. I have tried like below :
>
> while(1)
> {
> p1 = (char*)MEM_alloc(heap1, 100, 8);
> p2 = (char*)MEM_alloc(heap2, 100, 8);
>
> p1#; //I want to assigned new value to p1
>
> MEM_free(heap1,p1,100);
> MEM_free(heap2,p2,100);
> }
>
> but got error:
> a value of type
>