Within scope, will all declarations happen at the beginning of a function after compilation (in C)? The following examples shows a bit better what I am wondering. If something goes wrong with "ptr1", can I assume that ptr2 has been initialized to NULL?
int main()
{
int ret = 0;
void * ptr1 = NULL;
if (ret = do_ptr_work(ptr1))
goto done;
void * ptr2 = NULL;
if (ret = do_ptr_work(ptr2))
goto done;
done:
if (ptr1) {
free(ptr1);
ptr1 = NULL;
}
if (ptr2) {
free(ptr2);
ptr2 = NULL;
}
return ret;
}
Thanks, Chenz