I am trying to free a pointer that I assigned from a vector allocated with malloc()
, when I try to remove the first element(index [0]), it works, when I try to remove the second(index [1]) I receive this error:
malloc: *** error for object 0x100200218: pointer being freed was not allocated
The code:
table->t = malloc (sizeof (entry) * tam);
entry * elem = &table->t[1];
free(elem);