在经历了一些痛苦的经历后,我明白了悬摆指针和双重自由的问题。我正在寻求适当的解决方案 aStruct具有许多领域,其中包括其他阵列。 aStruct *A = NULL, *B = NULL;
A = (aStruct*) calloc(1, sizeof(sStruct));
B = A;
free_aStruct(A);
...
// Bunch of other code in v
这个非常简单的代码演示了野指针在复杂环境中导致的麻烦类型。 int main()
{
int *a1 = new int;
int *tmp = a1;
delete a1;
// Now, the tmp pointer is a wild pointer, it's dangerous.
int *a2 = new int;
de