First of all, this line
if(!(temp = (double*)realloc(data, capacity*sizeof(double))))
should look like
if(!(temp = realloc(data, capacity*sizeof(double))))
because as per this discussion we need not to cast the return value of
malloc() and family in
That said, to break down the statement,
temp = realloc(data, capacity*sizeof(double))gets evaluated. This statement reallocates
datato have a memory allocated equal to the size of
capacity*sizeof(double)bytes. The returned pointer is stored to
Then essentially the whole statement reduces to
if (! (temp)). This check for the success of the
realloc()call by checking the returned pointer against NULL.
realloc()failed, it returned NULL, and the
ifwill evaluate to TRUE, so the program will execute
exit(1);and get over.
realloc()is a success,
tempwill have a non-NULL pointer, thereby, the
ifcheck will fail and the program will continue normally.