diff options
author | Riccardo Spagni <ric@spagni.net> | 2014-10-06 08:51:44 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2014-10-06 08:52:16 +0200 |
commit | 3463f0ab52a84b79977c3e67177637e62265c89c (patch) | |
tree | 1e2077aa15fa18fcc9b00fa23c9514d46df6ef95 /external/unbound/compat/memmove.c | |
parent | fix for miniupnpc static compile under Windows (diff) | |
parent | added aabramov's gpg key (diff) | |
download | monero-3463f0ab52a84b79977c3e67177637e62265c89c.tar.xz |
Merge pull request #171
32be6ae added aabramov's gpg key (Riccardo Spagni)
010bfcf minor English wordlist tweaks (Riccardo Spagni)
9ef094b added unbound to external deps (Riccardo Spagni)
732493c split mnemonic printout over 3 lines (Riccardo Spagni)
Diffstat (limited to 'external/unbound/compat/memmove.c')
-rw-r--r-- | external/unbound/compat/memmove.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/external/unbound/compat/memmove.c b/external/unbound/compat/memmove.c new file mode 100644 index 000000000..0035bbf75 --- /dev/null +++ b/external/unbound/compat/memmove.c @@ -0,0 +1,43 @@ +/* + * memmove.c: memmove compat implementation. + * + * Copyright (c) 2001-2006, NLnet Labs. All rights reserved. + * + * See LICENSE for the license. +*/ + +#include <config.h> +#include <stdlib.h> + +void *memmove(void *dest, const void *src, size_t n); + +void *memmove(void *dest, const void *src, size_t n) +{ + uint8_t* from = (uint8_t*) src; + uint8_t* to = (uint8_t*) dest; + + if (from == to || n == 0) + return dest; + if (to > from && to-from < (int)n) { + /* to overlaps with from */ + /* <from......> */ + /* <to........> */ + /* copy in reverse, to avoid overwriting from */ + int i; + for(i=n-1; i>=0; i--) + to[i] = from[i]; + return dest; + } + if (from > to && from-to < (int)n) { + /* to overlaps with from */ + /* <from......> */ + /* <to........> */ + /* copy forwards, to avoid overwriting from */ + size_t i; + for(i=0; i<n; i++) + to[i] = from[i]; + return dest; + } + memcpy(dest, src, n); + return dest; +} |