以这段代码为例:
Struct* allocSomething(void) {
int n;
Struct *something = malloc(n*sizeof(Struct));
return something;
}
Struct* reallocSomething(Struct **s) {
int n;
Struct *something = realloc(*s, (n*sizeof(int)) - 1 * sizeof(Struct));
return something;
}
int main() {
Struct *point = allocSomething();
//code does something...
point = reallocSomething();
free(point);
}
我的问题是,在调用
reallocSomething
后,point
的地址是否仍然是由 allocSomething
返回的地址?例如,如果 point
的地址为 0x01
,当这个指针被 reallocSomething
重新分配时,那个地址是否仍然是 0x01
?