/*
**********************************************************************
-* Copyright (c) 2002-2004, International Business Machines
+* Copyright (c) 2002-2009, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Author: Alan Liu
}
U_NAMESPACE_END
+U_NAMESPACE_USE
//----------------------------------------------------------------------
// UDataMemory structures
info->formatVersion[0] == PNAME_FORMAT_VERSION;
}
-static UBool U_CALLCONV pname_cleanup() {
+static UBool U_CALLCONV pname_cleanup(void) {
if (UDATA) {
udata_close(UDATA);
UDATA = NULL;
* to load it, and return TRUE if the load succeeds.
*/
static inline UBool load() {
- umtx_lock(NULL);
- UBool f = (PNAME!=NULL);
- umtx_unlock(NULL);
+ UBool f;
+ UMTX_CHECK(NULL, (PNAME!=NULL), f);
return f || _load();
}
* which makes testing harder
*/
cmp.chars=(const char *)outBytes;
- cmp.propCompare=
- ds->outCharset==U_ASCII_FAMILY ?
- uprv_compareASCIIPropertyNames :
- uprv_compareEBCDICPropertyNames;
+ if (ds->outCharset==U_ASCII_FAMILY) {
+ cmp.propCompare=uprv_compareASCIIPropertyNames;
+ }
+ else {
+ cmp.propCompare=uprv_compareEBCDICPropertyNames;
+ }
uprv_sortArray(sortArray, tempMap->count, sizeof(NameAndIndex),
upname_compareRows, &cmp,
TRUE, pErrorCode);
if(U_FAILURE(*pErrorCode)) {
- udata_printError(ds, "upname_swap(NameToEnum).uprv_sortArray(%d items) failed - %s\n",
- tempMap->count, u_errorName(*pErrorCode));
+ udata_printError(ds, "upname_swap(NameToEnum).uprv_sortArray(%d items) failed\n",
+ tempMap->count);
return 0;
}
ValueMap *outValueMaps;
ValueMap valueMap;
- uint8_t *temp;
-
int32_t i;
inAliases=(const PropertyAliases *)inBytes;
* resort strings in name->enum maps
* swap value maps
*/
- temp=(uint8_t *)uprv_malloc(aliases.total_size);
- if(temp==NULL) {
+ LocalMemory<uint8_t> temp;
+ if(temp.allocateInsteadAndReset(aliases.total_size)==NULL) {
udata_printError(ds, "upname_swap(): unable to allocate temp memory (%d bytes)\n",
aliases.total_size);
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
return 0;
}
- uprv_memset(temp, 0, aliases.total_size);
/* swap properties->name groups map */
NonContiguousEnumToOffset::swap(ds, inBytes, length, outBytes,
- temp, aliases.enumToName_offset, pErrorCode);
+ temp.getAlias(), aliases.enumToName_offset, pErrorCode);
/* swap name->properties map */
NameToEnum::swap(ds, inBytes, length, outBytes,
- temp, aliases.nameToEnum_offset, pErrorCode);
+ temp.getAlias(), aliases.nameToEnum_offset, pErrorCode);
/* swap properties->value maps map */
NonContiguousEnumToOffset::swap(ds, inBytes, length, outBytes,
- temp, aliases.enumToValue_offset, pErrorCode);
+ temp.getAlias(), aliases.enumToValue_offset, pErrorCode);
/* enumerate all ValueMaps and swap them */
inValueMaps=(const ValueMap *)(inBytes+aliases.valueMap_offset);
if(valueMap.enumToName_offset!=0) {
EnumToOffset::swap(ds, inBytes, length, outBytes,
- temp, valueMap.enumToName_offset,
+ temp.getAlias(), valueMap.enumToName_offset,
pErrorCode);
} else if(valueMap.ncEnumToName_offset!=0) {
NonContiguousEnumToOffset::swap(ds, inBytes, length, outBytes,
- temp, valueMap.ncEnumToName_offset,
+ temp.getAlias(), valueMap.ncEnumToName_offset,
pErrorCode);
}
if(valueMap.nameToEnum_offset!=0) {
NameToEnum::swap(ds, inBytes, length, outBytes,
- temp, valueMap.nameToEnum_offset,
+ temp.getAlias(), valueMap.nameToEnum_offset,
pErrorCode);
}
}
outValueMaps, pErrorCode);
/* name groups and strings were swapped above */
-
- /* release temp */
- uprv_free(temp);
}
return aliases.total_size;