]>
git.saurik.com Git - apple/network_cmds.git/blob - unbound/compat/memmove.c
fe319bb49046bd2a18fe37ebfb490ea705a19c39
2 * memmove.c: memmove compat implementation.
4 * Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
6 * See LICENSE for the license.
12 void *memmove(void *dest
, const void *src
, size_t n
);
14 void *memmove(void *dest
, const void *src
, size_t n
)
16 uint8_t* from
= (uint8_t*) src
;
17 uint8_t* to
= (uint8_t*) dest
;
19 if (from
== to
|| n
== 0)
21 if (to
> from
&& to
-from
< (int)n
) {
22 /* to overlaps with from */
25 /* copy in reverse, to avoid overwriting from */
31 if (from
> to
&& from
-to
< (int)n
) {
32 /* to overlaps with from */
35 /* copy forwards, to avoid overwriting from */