假设我已经使用
现在关于IT的问题如下: -
malloc()
分配了内存,如果在我的代码中执行以下操作:char *newline = realloc ( oldline , newsize );
// Assuming oldline is the pointer to which the starting address
// of the memory which malloc() has returned, is assigned and,
// say, newsize is integer having 100 value.
现在关于IT的问题如下: -
- Is it necessary that
newline
will point to same address asoldline
, which holds the previous initial address? - Is it so that in this case,
oldline
will be freed(implicitly) andnewline
will take the charge of memory addressing? After the above code and after the work has been done, what should I do to free memory
free(newline);
or
free(oldline);
or both?