Annotation of researchv10no/cmd/sort/memmove.c, revision 1.1.1.1

1.1       root        1: /* Copyright AT&T Bell Laboratories, 1994 */
                      2: #include <stddef.h>
                      3: #include <string.h>
                      4: 
                      5: enum { S = sizeof(long) };
                      6: 
                      7: void *
                      8: memmove(void *to, const void *from, size_t n)
                      9: {
                     10:        char *out = to;
                     11:        const char *in = from;
                     12:        if(out > in) {
                     13:                in += n;
                     14:                out += n;
                     15:                if((in-out)%S == 0) {
                     16:                        for( ; (in-(char*)0)%S && n>0; n--)
                     17:                                *--out = *--in;
                     18:                        for( ; n>=S; n-=S) {
                     19:                                out -= S;
                     20:                                in -= S;
                     21:                                *(long*)out = *(long*)in;
                     22:                        }
                     23:                }
                     24:                for( ; n>0; n--)
                     25:                        *--out = *--in;
                     26:        } else {
                     27:                if((in-out)%S == 0) {
                     28:                        for( ; (in-(char*)0)%S && n>0; n--)
                     29:                                *out++ = *in++;
                     30:                        for( ; n>=S; n-=S) {
                     31:                                *(long*)out = *(long*)in;
                     32:                                out += S;
                     33:                                in += S;
                     34:                        }
                     35:                }
                     36:                for( ; n>0; n--)
                     37:                        *out++ = *in++;
                     38:        }
                     39:        return(to);
                     40: }

unix.superglobalmegacorp.com

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