File:  [Research Unix] / researchv10dc / libc / gen / memmove.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 3 months ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Dan Cross

/* Copyright AT&T Bell Laboratories, 1993 */
#include <stddef.h>

extern void *memcpy(void*, void*, size_t);

void *
memmove(void *to, void *from, register size_t n)
{
	register char *out = to;
	register char *in = from;

	if(n <= 0)	/* works if size_t is signed or not */
		;
	else if(in + n <= out || out + n <= in)
		return(memcpy(to, from, n));	/* hope it's fast*/
	else if(out < in)
		do
			*out++ = *in++;
		while(--n > 0);
	else {
		out += n;
		in += n;
		do
			*--out = *--in;
		while(--n > 0);
	}
	return(to);
}

unix.superglobalmegacorp.com

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