memmove

Doug McDonald mcdonald at aries.scs.uiuc.edu
Sun Jun 17 23:56:23 AEST 1990


In article <1307 at proto.COM> you (i.e. somebody, I lost the name) write:
>In article <16891 at haddock.ima.isc.com>, karl at haddock.ima.isc.com (Karl Heuer) 
>writes:
>> #include <string.h>
>> void *memmove(void *adest, void *asrc, size_t n) {
>>     if (n != 0) {
>>         register char *dest = (char *)adest;
>>         register char *src = (char *)asrc;
>>         if (src > dest) {
>
               ^^^^^^^^^^
>The comparisions 'if(src > dest)' and 'if(src < dest)' will only compare
>the offset with most (all?) C compilers for the 80x86.  

They will compare segments if it is necessary: in huge model. 

Its worse than that: the indicated construct is not legal C. You don't
know that adest and asrc are in the same array or struct.
Its just plain illegal.

Memmove cannot be written in C. That is probably why it is included in
the library. In general it will require operating system calls.

Doug McDonald



More information about the Comp.lang.c mailing list