mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* missing.h, missing/memcmp.c, missing/memmove.c:
ANSI compatible interface. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f44333cbff
commit
c0851c650f
4 changed files with 19 additions and 16 deletions
|
|
@ -1,22 +1,21 @@
|
|||
/* public domain rewrite of memcmp(3) */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void *
|
||||
memmove (d, s, n)
|
||||
void *d, *s;
|
||||
int n;
|
||||
memmove(void *d, const void *s, size_t n)
|
||||
{
|
||||
char *dst = d;
|
||||
char *src = s;
|
||||
void *ret = dst;
|
||||
char *dst = (char *)d;
|
||||
const char *src = (const char *)s;
|
||||
|
||||
if (src < dst) {
|
||||
src += n;
|
||||
dst += n;
|
||||
while (n--)
|
||||
for (; n; --n)
|
||||
*--dst = *--src;
|
||||
}
|
||||
else if (dst < src)
|
||||
while (n--)
|
||||
for (; n; --n)
|
||||
*dst++ = *src++;
|
||||
return ret;
|
||||
return d;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue