/*********************************************************
- * Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
*/
// Most lower-case operations don't change the length of the string.
- utf8Dest = (char *)Util_SafeMalloc(destCapacity);
+ utf8Dest = Util_SafeMalloc(destCapacity);
caseMap = ucasemap_open(locale, 0, &status);
if (U_FAILURE(status)) {
// If we need a bigger buffer, then reallocate and retry.
destCapacity = destLen + 1;
- utf8Dest = (char *)Util_SafeRealloc(utf8Dest, destCapacity);
+ utf8Dest = Util_SafeRealloc(utf8Dest, destCapacity);
status = U_ZERO_ERROR;
destLen = ucasemap_utf8ToLower(caseMap,
if (U_SUCCESS(status) && status != U_STRING_NOT_TERMINATED_WARNING) {
result = utf8Dest;
} else {
- ASSERT(U_SUCCESS(status));
- ASSERT(status != U_STRING_NOT_TERMINATED_WARNING);
+ DEBUG_ONLY(Warning("%s: Invalid UTF-8 string detected.\n",
+ __FUNCTION__));
+ free(utf8Dest);
}
return result;
char *result = NULL;
// Most upper-case operations don't change the length of the string.
- utf8Dest = (char *)Util_SafeMalloc(destCapacity);
+ utf8Dest = Util_SafeMalloc(destCapacity);
caseMap = ucasemap_open(locale, 0, &status);
if (U_FAILURE(status)) {
// If we need a bigger buffer, then reallocate and retry.
destCapacity = destLen + 1;
- utf8Dest = (char *)Util_SafeRealloc(utf8Dest, destCapacity);
+ utf8Dest = Util_SafeRealloc(utf8Dest, destCapacity);
status = U_ZERO_ERROR;
destLen = ucasemap_utf8ToUpper(caseMap,
if (U_SUCCESS(status) && status != U_STRING_NOT_TERMINATED_WARNING) {
result = utf8Dest;
} else {
- ASSERT(U_SUCCESS(status));
- ASSERT(status != U_STRING_NOT_TERMINATED_WARNING);
+ DEBUG_ONLY(Warning("%s: Invalid UTF-8 string detected.\n",
+ __FUNCTION__));
+ free(utf8Dest);
}
return result;
}
+
/*
* "ucasemap_utf8ToTitle" is not in version 3.6 of the ICU library,
* which appears to be the default on many systems...
char *result = NULL;
// Most title-case operations don't change the length of the string.
- utf8Dest = (char *)Util_SafeMalloc(destCapacity);
+ utf8Dest = Util_SafeMalloc(destCapacity);
caseMap = ucasemap_open(locale, 0, &status);
if (U_FAILURE(status)) {
// If we need a bigger buffer, then reallocate and retry.
destCapacity = destLen + 1;
- utf8Dest = (char *)Util_SafeRealloc(utf8Dest, destCapacity);
+ utf8Dest = Util_SafeRealloc(utf8Dest, destCapacity);
status = U_ZERO_ERROR;
destLen = ucasemap_utf8ToTitle(caseMap,
if (U_SUCCESS(status) && status != U_STRING_NOT_TERMINATED_WARNING) {
result = utf8Dest;
} else {
- ASSERT(U_SUCCESS(status));
- ASSERT(status != U_STRING_NOT_TERMINATED_WARNING);
+ DEBUG_ONLY(Warning("%s: Invalid UTF-8 string detected.\n",
+ __FUNCTION__));
+ free(utf8Dest);
}
return result;