RE: Freeing an array of pointer
For one thing, you're not checking the return from malloc (). The fact that you can write to it
does not necessarily mean that malloc was successful.
And I'm confused as to why you're malloc'ing space that way for an array of integer
pointers. On the 10th iteration, you are malloc'ing ( (9 + 1) * sizeof (int))
double_buffer is now pointing to a space equivalent to the size of 10 ints.
Is that really what you want?
for (i = 0; i < 10; i++)
double_buffer[i] = (int *) malloc (sizeof (int));
printf ("Error %d during malloc on %d\n", errno, i);