Annotation of researchv10dc/libc/gen/memmove.c, revision 1.1

1.1     ! root        1: /* Copyright AT&T Bell Laboratories, 1993 */
        !             2: #include <stddef.h>
        !             3: 
        !             4: extern void *memcpy(void*, void*, size_t);
        !             5: 
        !             6: void *
        !             7: memmove(void *to, void *from, register size_t n)
        !             8: {
        !             9:        register char *out = to;
        !            10:        register char *in = from;
        !            11: 
        !            12:        if(n <= 0)      /* works if size_t is signed or not */
        !            13:                ;
        !            14:        else if(in + n <= out || out + n <= in)
        !            15:                return(memcpy(to, from, n));    /* hope it's fast*/
        !            16:        else if(out < in)
        !            17:                do
        !            18:                        *out++ = *in++;
        !            19:                while(--n > 0);
        !            20:        else {
        !            21:                out += n;
        !            22:                in += n;
        !            23:                do
        !            24:                        *--out = *--in;
        !            25:                while(--n > 0);
        !            26:        }
        !            27:        return(to);
        !            28: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.