say I have a list of structures:
Code:
struct buffer
{
char *buffer;
struct buffer *next;
}
Ok I malloced a bunch of structures that link to each other making sure next is null if there aren't anymore commands in the buffer. Can I free iter and still access what iter->next was pointing to if it was malloced data?
Code:
void free_d_buffer_q(struct buffer *q)
{
struct buffer *iter;
iter = q;
while(iter !=0)
{
if( iter->buffer )
free(iter->buffer);
q = iter->next;
free(iter);
iter = q;
}
}