calling memcpy for arrays (perhaps not on all occacions, still TODO) and free