I'm writing a bit of code for a class, but since I have no experience in C I'm a bit unsure of what the code I've written actually does. Particularly what the memory looks like. Here's the relevant bits:
typedef struct listnode *Node; typedef struct listnode { void *data; Node next; Node previous; } Listnode; typedef struct listhead *LIST; typedef struct listhead { int size; Node first; Node last; Node current; } Listhead; #define HALLOCSIZE 50 static LIST hallocbuf[HALLOCSIZE]; static LIST *hallocp = hallocbuf; LIST *CreateList() { if(hallocbuf + HALLOCSIZE - hallocp >= 1) { LIST temp; temp->size = 0; temp->first = NULL; temp->last = NULL; temp->current = NULL; *hallocp = temp; return hallocp; }else return NULL; } So my question is, in the CreateList function, how is the program allocating memory for temp? And does the code *hallocp = temp copy the temp LIST into the hallocbuf array? I am trying to have all my LIST structs sit in the allocated memory for hallocbuf. Is this what I'm doing? I'm a bit uncertain of how the typedef, structs and pointers play together.
Thanks!