Page 1 of 1

use of calloc()

PostPosted: Mar 28, 2002 @ 5:46am
by AnanoMouse
ok, I am trying to learn how to program for the ppc and I could use some help. I have been reading through some tutorials on the net on programing. Ok, here is my question.

What is the exact purpose of calloc()

and

In this case, what does the following mean...

struct Misc
{
int x;
Misc y;
}*x;

void somefunction()
{
calloc(1, x);
}

(I think that is the correct syntax, but I am not positive. Oh wise programmers, please help).

PostPosted: Mar 28, 2002 @ 6:26am
by djr2cool
calloc, and malloc are used to create buffers.

the first thing is a pointer to a struct *x, also looks like some sort of linked list maybe.. seeing how there is a reference to itself inside the struct..

i also didnt think calloc was used in that way.. i thought it was used more like

unsigned short *Buff = (unsigned short*)calloc(n1,n2);

n1 would be how many slots in the buffer and n2 s the size of each slot in bytes.. it may be reversed.

PostPosted: Mar 28, 2002 @ 6:55am
by RICoder