temp is allocated in the space used for objects with "automatic storage duration" - this is usually done at run time, but you don't need to know the details. The space is freed when the block in which it was allocated exits (in your case, when you press return ).
Line *hallocp = temp; really copies the temp value to the memory pointed to by hallocp , which is equal to hallocbuf[0] .
The problem is that temp is just a pointer, and it does not point to anything. This is called a dangling pointer. This means that when you try to access what it points to, you have an error. This occurs on the following lines:
temp->size = 0; temp->first = NULL; temp->last = NULL; temp->current = NULL;
You cannot have your structures sit in the memory allocated for hallocbuf because it has no place for structures - it is just an array of pointers, not an array of structures.
source share