]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/ustring.cpp
ICU-551.24.tar.gz
[apple/icu.git] / icuSources / common / ustring.cpp
index 3210cfc215e2ec4d59c039beee5bd9a5d3baa67b..40d23c06aea74d1eda5e9fd605181840f500031c 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 1998-2011, International Business Machines
+*   Copyright (C) 1998-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
@@ -1112,12 +1112,18 @@ u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number) {
 
 U_CAPI UChar * U_EXPORT2
 u_memcpy(UChar *dest, const UChar *src, int32_t count) {
-    return (UChar *)uprv_memcpy(dest, src, count*U_SIZEOF_UCHAR);
+    if(count > 0) {
+        uprv_memcpy(dest, src, count*U_SIZEOF_UCHAR);
+    }
+    return dest;
 }
 
 U_CAPI UChar * U_EXPORT2
 u_memmove(UChar *dest, const UChar *src, int32_t count) {
-    return (UChar *)uprv_memmove(dest, src, count*U_SIZEOF_UCHAR);
+    if(count > 0) {
+        uprv_memmove(dest, src, count*U_SIZEOF_UCHAR);
+    }
+    return dest;
 }
 
 U_CAPI UChar * U_EXPORT2
@@ -1480,7 +1486,7 @@ u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCod
 */
 
 #define STRING_HASH(TYPE, STR, STRLEN, DEREF) \
-    int32_t hash = 0;                         \
+    uint32_t hash = 0;                        \
     const TYPE *p = (const TYPE*) STR;        \
     if (p != NULL) {                          \
         int32_t len = (int32_t)(STRLEN);      \
@@ -1491,7 +1497,7 @@ u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCod
             p += inc;                         \
         }                                     \
     }                                         \
-    return hash
+    return static_cast<int32_t>(hash)
 
 /* Used by UnicodeString to compute its hashcode - Not public API. */
 U_CAPI int32_t U_EXPORT2