]> granicus.if.org Git - icu/commitdiff
ICU-13395 Remove uprv_checkValidMemory(). Was incompatible with memory and thread...
authorAndy Heninger <andy.heninger@gmail.com>
Thu, 30 Nov 2017 21:58:56 +0000 (21:58 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Thu, 30 Nov 2017 21:58:56 +0000 (21:58 +0000)
X-SVN-Rev: 40678

icu4c/source/common/cmemory.cpp
icu4c/source/common/cmemory.h
icu4c/source/common/cstring.h

index 2176c929e84fbc3b031a40576e296f07ac14a110..663c1411e4cb3b8f9dbf3eddb46139d3c8aa2f57 100644 (file)
@@ -41,30 +41,6 @@ static int n=0;
 static long b=0; 
 #endif
 
-#if U_DEBUG
-
-static char gValidMemorySink = 0;
-
-U_CAPI void uprv_checkValidMemory(const void *p, size_t n) {
-    /*
-     * Access the memory to ensure that it's all valid.
-     * Load and save a computed value to try to ensure that the compiler
-     * does not throw away the whole loop.
-     * A thread analyzer might complain about un-mutexed access to gValidMemorySink
-     * which is true but harmless because no one ever uses the value in gValidMemorySink.
-     */
-    const char *s = (const char *)p;
-    char c = gValidMemorySink;
-    size_t i;
-    U_ASSERT(p != NULL);
-    for(i = 0; i < n; ++i) {
-        c ^= s[i];
-    }
-    gValidMemorySink = c;
-}
-
-#endif  /* U_DEBUG */
-
 U_CAPI void * U_EXPORT2
 uprv_malloc(size_t s) {
 #if U_DEBUG && defined(UPRV_MALLOC_COUNT)
index ddf8e49a6817c21dab54fdd457ffbbed06507818..5cb52993abcc5bf99fb3ae93b5db03717791c66b 100644 (file)
 #include <stdio.h>
 #endif
 
-#if U_DEBUG
-
-/*
- * The C++ standard requires that the source pointer for memcpy() & memmove()
- * is valid, not NULL, and not at the end of an allocated memory block.
- * In debug mode, we read one byte from the source point to verify that it's
- * a valid, readable pointer.
- */
-
-U_CAPI void uprv_checkValidMemory(const void *p, size_t n);
-
-#define uprv_memcpy(dst, src, size) ( \
-    uprv_checkValidMemory(src, 1), \
-    U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size))
-#define uprv_memmove(dst, src, size) ( \
-    uprv_checkValidMemory(src, 1), \
-    U_STANDARD_CPP_NAMESPACE memmove(dst, src, size))
-
-#else
 
 #define uprv_memcpy(dst, src, size) U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size)
 #define uprv_memmove(dst, src, size) U_STANDARD_CPP_NAMESPACE memmove(dst, src, size)
 
-#endif  /* U_DEBUG */
-
 /**
  * \def UPRV_LENGTHOF
  * Convenience macro to determine the length of a fixed array at compile-time.
index 2232efcda5c0ef9847552d224c3cf9faf5320d29..ed0b1a7c8b0be863e7dd297b4e47a978ebb15a4d 100644 (file)
 #define uprv_strchr(s, c) U_STANDARD_CPP_NAMESPACE strchr(s, c)
 #define uprv_strstr(s, c) U_STANDARD_CPP_NAMESPACE strstr(s, c)
 #define uprv_strrchr(s, c) U_STANDARD_CPP_NAMESPACE strrchr(s, c)
-
-#if U_DEBUG
-
-#define uprv_strncpy(dst, src, size) ( \
-    uprv_checkValidMemory(src, 1), \
-    U_STANDARD_CPP_NAMESPACE strncpy(dst, src, size))
-#define uprv_strncmp(s1, s2, n) ( \
-    uprv_checkValidMemory(s1, 1), \
-    uprv_checkValidMemory(s2, 1), \
-    U_STANDARD_CPP_NAMESPACE strncmp(s1, s2, n))
-#define uprv_strncat(dst, src, n) ( \
-    uprv_checkValidMemory(src, 1), \
-    U_STANDARD_CPP_NAMESPACE strncat(dst, src, n))
-
-#else
-
 #define uprv_strncpy(dst, src, size) U_STANDARD_CPP_NAMESPACE strncpy(dst, src, size)
 #define uprv_strncmp(s1, s2, n) U_STANDARD_CPP_NAMESPACE strncmp(s1, s2, n)
 #define uprv_strncat(dst, src, n) U_STANDARD_CPP_NAMESPACE strncat(dst, src, n)
 
-#endif  /* U_DEBUG */
-
 /**
  * Is c an ASCII-repertoire letter a-z or A-Z?
  * Note: The implementation is specific to whether ICU is compiled for