3

This is how i allocate the space needed:

char *all_type_str;
...
all_type_str = malloc(sizeof(char)*4);

setting string:

strcpy(all_type_str,"all");

setting it in a different array:

...
values[0].value = all_type_str;

and freeing values array:

for (i=0; i<arrSize; i++)
{
    free(values[i].value); //   <-- SIGABRT
}
free(values);

allocating values array:

values = malloc(sizeof(struct cnf)*adjArrSize);

using gdb i can see that i have a not null pointer with the wanted "all" string

but for some reason i get SIGABRT when trying to free the first place in the array.

any idea why this is happening?

4

1 回答 1

0

也许您的指针超出范围?这是同一个功能吗?除非我们看到完整的代码,否则我们无法判断。

于 2013-10-15T22:06:40.290 回答