Original Post
Hi!
I have a following malloc/free problem:
This seems to work:
//allocating memory n+1 doubles double *pNew = (double*) malloc((n+1)*sizeof(double)); //free memory free(pNew);This seems not to free all memory:
//allocating memory n+1 doubles double *pNew = (double*) malloc((n+1)*sizeof(double)); //temporary pointer double *pTemp = pNew; //free memory free(pTemp);My question is: How does free know, how much memory was allcocated? Or can I use only use example 1 to free the allocated memory? Does example 2 only free the memory for one double where pTemp points to or the memory block, which was allocated before? Thanks for your help! The Wild Wild West - Desperado!