# HG changeset patch # User asl # Date 1199621861 0 # Node ID fcbc1384c4e3e71f1e97a55c41e720a099414c8a # Parent 1f046a6b2a6cfd024838e700303d2ff37f0c0c4d * src/dlmalloc.cxx (MALLOC_COPY): * cdl/memalloc.cdl: Use memmove instead of memcpy which can go wrong in realloc() when the new and old block overlaps. CYGIMP_MEMALLOC_ALLOCATOR_DLMALLOC_USE_MEMCPY has been retained instead of being renamed to ..._MEMMOVE to help backward compatibility with older configurations. Thanks to Oyvind Harboe and Dave Lawrence. diff --git a/packages/services/memalloc/common/current/ChangeLog b/packages/services/memalloc/common/current/ChangeLog --- a/packages/services/memalloc/common/current/ChangeLog +++ b/packages/services/memalloc/common/current/ChangeLog @@ -1,3 +1,13 @@ +2008-01-06 Andrew Lunn + + * src/dlmalloc.cxx (MALLOC_COPY): + * cdl/memalloc.cdl: Use memmove instead of memcpy which can go + wrong in realloc() when the new and old block overlaps. + CYGIMP_MEMALLOC_ALLOCATOR_DLMALLOC_USE_MEMCPY has been retained + instead of being renamed to ..._MEMMOVE to help backward + compatibility with older configurations. Thanks to Oyvind Harboe + and Dave Lawrence. + 2007-11-05 Oyvind Harboe * cdl/memalloc.cdl: Added option CYGBLD_MEMALLOC_MALLOC_EXTERNAL_JOIN_H @@ -10,7 +20,6 @@ 2007-10-24 Jonathan Larmour diff --git a/packages/services/memalloc/common/current/cdl/memalloc.cdl b/packages/services/memalloc/common/current/cdl/memalloc.cdl --- a/packages/services/memalloc/common/current/cdl/memalloc.cdl +++ b/packages/services/memalloc/common/current/cdl/memalloc.cdl @@ -176,11 +176,11 @@ cdl_package CYGPKG_MEMALLOC { } cdl_option CYGIMP_MEMALLOC_ALLOCATOR_DLMALLOC_USE_MEMCPY { - display "Use system memcpy() and memset()" + display "Use system memmove() and memset()" requires CYGPKG_ISOINFRA default_value { 0 != CYGPKG_ISOINFRA } description " - This may be used to control whether memset() and memcpy() + This may be used to control whether memset() and memmove() are used within the implementation. The alternative is to use some macro equivalents, which some people report are faster in some circumstances." diff --git a/packages/services/memalloc/common/current/src/dlmalloc.cxx b/packages/services/memalloc/common/current/src/dlmalloc.cxx --- a/packages/services/memalloc/common/current/src/dlmalloc.cxx +++ b/packages/services/memalloc/common/current/src/dlmalloc.cxx @@ -295,7 +295,7 @@ #ifdef CYGIMP_MEMALLOC_ALLOCATOR_DLMALLOC_USE_MEMCPY -#include // memcpy, memset +#include // memmove, memset /* The following macros are only invoked with (2n+1)-multiples of INTERNAL_SIZE_T units, with a positive integer n. This is exploited @@ -333,7 +333,7 @@ do { *mcdst++ = *mcsrc++; \ *mcdst++ = *mcsrc++; \ *mcdst = *mcsrc ; \ - } else memcpy(dest, src, mcsz); \ + } else memmove(dest, src, mcsz); \ } while(0) #else /* !CYGIMP_MEMALLOC_ALLOCATOR_DLMALLOC_USE_MEMCPY */