Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2005-06-03 22:57:30 +0400
committerJeff Johnston <jjohnstn@redhat.com>2005-06-03 22:57:30 +0400
commit15c04fd16e2f6a8725311eeff9f5093524c6cf4f (patch)
treee58bc3961641777ae6543f485c7b71220605932d /newlib
parentd9f491a77d770b849045182efed1e07a2efd0563 (diff)
2005-06-03 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/mallocr.c (MALLOC_COPY): Switch to use memmove instead of memcpy.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog5
-rw-r--r--newlib/libc/stdlib/mallocr.c8
2 files changed, 12 insertions, 1 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 6e01cd3d0..52df833e0 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,8 @@
+2005-06-03 Jeff Johnston <jjohnstn@redhat.com>
+
+ * libc/stdlib/mallocr.c (MALLOC_COPY): Switch to use memmove
+ instead of memcpy.
+
2005-05-12 Jeff Johnston <jjohnstn@redhat.com>
* configure.host (mn10300-*): Add long long I/O support by default.
diff --git a/newlib/libc/stdlib/mallocr.c b/newlib/libc/stdlib/mallocr.c
index 71886c14f..02f6a5d15 100644
--- a/newlib/libc/stdlib/mallocr.c
+++ b/newlib/libc/stdlib/mallocr.c
@@ -487,6 +487,10 @@ extern void __malloc_unlock();
#define HAVE_MEMCPY
+/* Although the original macro is called USE_MEMCPY, newlib actually
+ uses memmove to handle cases whereby a platform's memcpy implementation
+ copies backwards and thus destructive overlap may occur in realloc
+ whereby we are reclaiming free memory prior to the old allocation. */
#ifndef USE_MEMCPY
#ifdef HAVE_MEMCPY
#define USE_MEMCPY 1
@@ -500,9 +504,11 @@ extern void __malloc_unlock();
#if __STD_C
void* memset(void*, int, size_t);
void* memcpy(void*, const void*, size_t);
+void* memmove(void*, const void*, size_t);
#else
Void_t* memset();
Void_t* memcpy();
+Void_t* memmove();
#endif
#endif
@@ -544,7 +550,7 @@ do { \
*mcdst++ = *mcsrc++; \
*mcdst++ = *mcsrc++; \
*mcdst = *mcsrc ; \
- } else memcpy(dest, src, mcsz); \
+ } else memmove(dest, src, mcsz); \
} while(0)
#else /* !USE_MEMCPY */