#include "olsontz.h"
#include "uinvchar.h"
-static UMutex gZoneMetaLock = U_MUTEX_INITIALIZER;
+static icu::UMutex gZoneMetaLock;
// CLDR Canonical ID mapping table
static UHashtable *gCanonicalIDCache = NULL;
id[len] = (char) 0; // Make sure it is null terminated.
// replace '/' with ':'
- char *p = id;
- while (*p++) {
- if (*p == '/') {
- *p = ':';
+ char *q = id;
+ while (*q++) {
+ if (*q == '/') {
+ *q = ':';
}
}
mzMappings = new UVector(deleteOlsonToMetaMappingEntry, NULL, status);
if (U_FAILURE(status)) {
delete mzMappings;
- deleteOlsonToMetaMappingEntry(entry);
+ mzMappings = NULL;
uprv_free(entry);
break;
}
ucln_i18n_registerCleanup(UCLN_I18N_ZONEMETA, zoneMeta_cleanup);
UErrorCode status = U_ZERO_ERROR;
- gMetaZoneIDTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, &status);
+ gMetaZoneIDTable = uhash_open(uhash_hashUChars, uhash_compareUChars, NULL, &status);
if (U_FAILURE(status) || gMetaZoneIDTable == NULL) {
gMetaZoneIDTable = NULL;
return;
}
- uhash_setKeyDeleter(gMetaZoneIDTable, uprv_deleteUObject);
- // No valueDeleter, because the vector maintain the value objects
gMetaZoneIDs = new UVector(NULL, uhash_compareUChars, status);
if (U_FAILURE(status) || gMetaZoneIDs == NULL) {
gMetaZoneIDs = NULL;
UResourceBundle *rb = ures_openDirect(NULL, gMetaZones, &status);
UResourceBundle *bundle = ures_getByKey(rb, gMapTimezonesTag, NULL, &status);
- UResourceBundle res;
- ures_initStackObject(&res);
+ StackUResourceBundle res;
while (U_SUCCESS(status) && ures_hasNext(bundle)) {
- ures_getNextResource(bundle, &res, &status);
+ ures_getNextResource(bundle, res.getAlias(), &status);
if (U_FAILURE(status)) {
break;
}
- const char *mzID = ures_getKey(&res);
- int32_t len = uprv_strlen(mzID);
+ const char *mzID = ures_getKey(res.getAlias());
+ int32_t len = static_cast<int32_t>(uprv_strlen(mzID));
UChar *uMzID = (UChar*)uprv_malloc(sizeof(UChar) * (len + 1));
if (uMzID == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
}
u_charsToUChars(mzID, uMzID, len);
uMzID[len] = 0;
- UnicodeString *usMzID = new UnicodeString(uMzID);
- if (uhash_get(gMetaZoneIDTable, usMzID) == NULL) {
+ if (uhash_get(gMetaZoneIDTable, uMzID) == NULL) {
gMetaZoneIDs->addElement((void *)uMzID, status);
- uhash_put(gMetaZoneIDTable, (void *)usMzID, (void *)uMzID, &status);
+ uhash_put(gMetaZoneIDTable, (void *)uMzID, (void *)uMzID, &status);
} else {
uprv_free(uMzID);
- delete usMzID;
}
}
- ures_close(&res);
ures_close(bundle);
ures_close(rb);
if (gMetaZoneIDTable == NULL) {
return NULL;
}
- return (const UChar*)uhash_get(gMetaZoneIDTable, &mzid);
+ UnicodeString localMzid = mzid;
+ return (const UChar*)uhash_get(gMetaZoneIDTable, localMzid.getTerminatedBuffer());
}
const UChar*
negative = TRUE;
tmp = -offset;
}
- int32_t hour, min, sec;
+ uint8_t hour, min, sec;
tmp /= 1000;
- sec = tmp % 60;
+ sec = static_cast<uint8_t>(tmp % 60);
tmp /= 60;
- min = tmp % 60;
- hour = tmp / 60;
+ min = static_cast<uint8_t>(tmp % 60);
+ hour = static_cast<uint8_t>(tmp / 60);
UnicodeString zid;
formatCustomID(hour, min, sec, negative, zid);