I am writing some school project, and I need to swap two items of void* pointer array. I can do this with something like following code:
void swap(void *base, int len, int width)
{
void *p = malloc(width);
memcpy(p,base,width);
memcpy(base,(char*)base+width,width);
memcpy((char*)base+width,p,width);
free(p);
}
But I need to swap items WITHOUT memcpy, only with malloc, realloc and free. Is that even possible?
Thank you