Revert "mlibc: Use memmove in realloc."
This reverts commit f47a21e3cb4814c4a30d10ff59e5c947441725e9.
This commit is contained in:
parent
1270c767cd
commit
7cad0671f3
|
@ -134,6 +134,18 @@ localtime (time_t const *timep)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void *
|
||||
memmove (void *dest, void const *src, size_t n)
|
||||
{
|
||||
if (dest < src)
|
||||
return memcpy (dest, src, n);
|
||||
char *p = dest + n;
|
||||
char const *q = src +n;
|
||||
while (n--)
|
||||
*--p = *--q;
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *
|
||||
memset (void *s, int c, size_t n)
|
||||
{
|
||||
|
|
14
lib/libc.c
14
lib/libc.c
|
@ -294,25 +294,13 @@ memcpy (void *dest, void const *src, size_t n)
|
|||
return dest;
|
||||
}
|
||||
|
||||
void *
|
||||
memmove (void *dest, void const *src, size_t n)
|
||||
{
|
||||
if (dest < src)
|
||||
return memcpy (dest, src, n);
|
||||
char *p = dest + n;
|
||||
char const *q = src +n;
|
||||
while (n--)
|
||||
*--p = *--q;
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *
|
||||
realloc (void *ptr, size_t size)
|
||||
{
|
||||
void *new = malloc (size);
|
||||
if (ptr && new)
|
||||
{
|
||||
memmove (new, ptr, size);
|
||||
memcpy (new, ptr, size);
|
||||
free (ptr);
|
||||
}
|
||||
return new;
|
||||
|
|
Loading…
Reference in a new issue