2 * Part of the D programming language runtime library.
6 * Copyright (C) 2004-2007 by Digital Mars, www.digitalmars.com
7 * Written by Walter Bright
9 * This software is provided 'as-is', without any express or implied
10 * warranty. In no event will the authors be held liable for any damages
11 * arising from the use of this software.
13 * Permission is granted to anyone to use this software for any purpose,
14 * including commercial applications, and to alter it and redistribute it
15 * freely, in both source and binary form, subject to the following
18 * o The origin of this software must not be misrepresented; you must not
19 * claim that you wrote the original software. If you use this software
20 * in a product, an acknowledgment in the product documentation would be
21 * appreciated but is not required.
22 * o Altered source versions must be plainly marked as such, and must not
23 * be misrepresented as being the original software.
24 * o This notice may not be removed or altered from any source
29 * Modified by Sean Kelly for use with the D Runtime Project
37 debug import stdc.stdio;
42 byte[] _d_arraycopy(size_t size, byte[] from, byte[] to)
44 debug printf("f = %p,%d, t = %p,%d, size = %d\n",
45 from.ptr, from.length, to.ptr, to.length, size);
47 if (to.length != from.length)
49 throw new Exception("lengths don't match for array copy");
51 else if (to.ptr + to.length * size <= from.ptr ||
52 from.ptr + from.length * size <= to.ptr)
54 memcpy(to.ptr, from.ptr, to.length * size);
58 throw new Exception("overlapping array copy");