[Solved] Malloc , Realloc , Memset : Struct pointers , arrays of char, int

Error was in v_push_back implementation : v->e_array = check_a(memcpy((void*)((char*)v->e_array + (v->no_e * v->e_sz)) ,new_val, v->e_sz)); //pointer has not to be saved check_a(memcpy((void*)((char*)v->e_array + (v->no_e * v->e_sz)) ,new_val, v->e_sz)); Because memcpy returns a pointer , in this case, to the last element of the array so we would have lost access to all previous memory solved … Read more

[Solved] using realloc in C with malloc [closed]

if (newsize == 0) { free(ptr); return; } if (ptr == NULL) return malloc(size); // otherwise do a true realloc As for What if there is not a contigious size of the size wanted. Then realloc returns NULL and sets errno to indicate the error. 9 solved using realloc in C with malloc [closed]