siri.paddu
BAN USER- 1of 1 vote
AnswersImplement memmove .
- siri.paddu in United States
Dont use extra memory.
How to optimise it further?| Report Duplicate | Flag | PURGE
Google
ya. The solution is a straight reject.
You need to typecast the void pointers to appropriate data types.
Repgeraldgloria02, Android test engineer at Achieve Internet
I am a personal trainer. I design programs and provide nutritional advice and coaching. I wanted to share my knowledge ...
Repjanistbennett, Blockchain Developer at AMD
I am JanisBennett working as a journalist, having years of experience in my career. I have covered various stories.Great ...
Repneshujaha, Member Technical Staff at BMO Harris Bank
I am Neshu, a Camera Operator with a creative eye for detail and dedication to quality work. I am always ...
Repabig8485, Apple Phone Number available 24/7 for our Customers at ABC TECH SUPPORT
Hello, I'm Abigail and I'm from Hugo City. I maintain customer loyalty and keep a diverse group of ...
void * memove(void *dest, void *src, size_t n)
- siri.paddu December 06, 2012{
char *d =(char *)dest;
char *s =(char *)src;
if(s == d)
return dest;
if(s < d) {
//copy from back
s=s+n-1;
d=d+n-1;
while(n--)
{
*d-- = *s--;
}
}
else {
//copy from front
while(n--)
*d++=*s++;
}
return dest;
}
optimisation suggested to use int and float may not work all time as the address need to be exact divisible of 4 or 8 depending on machine and memory alignment.
The while loop can be optimised by using loop unrolling.
This was the answer expected by the interviewer.