Only call memcpy when the length is larger than 0.