| OLD | NEW |
| (Empty) |
| 1 diff --git a/source/common/cmemory.c b/source/common/cmemory.c | |
| 2 index cd3ccac..42885f2 100644 | |
| 3 --- a/source/common/cmemory.c | |
| 4 +++ b/source/common/cmemory.c | |
| 5 @@ -1,7 +1,7 @@ | |
| 6 /* | |
| 7 ****************************************************************************** | |
| 8 * | |
| 9 -* Copyright (C) 2002-2012, International Business Machines | |
| 10 +* Copyright (C) 2002-2015, International Business Machines | |
| 11 * Corporation and others. All Rights Reserved. | |
| 12 * | |
| 13 ****************************************************************************** | |
| 14 @@ -33,10 +33,6 @@ static UMemAllocFn *pAlloc; | |
| 15 static UMemReallocFn *pRealloc; | |
| 16 static UMemFreeFn *pFree; | |
| 17 | |
| 18 -/* Flag indicating whether any heap allocations have happened. | |
| 19 - * Used to prevent changing out the heap functions after allocations have bee
n made */ | |
| 20 -static UBool gHeapInUse; | |
| 21 - | |
| 22 #if U_DEBUG && defined(UPRV_MALLOC_COUNT) | |
| 23 #include <stdio.h> | |
| 24 static int n=0; | |
| 25 @@ -78,7 +74,6 @@ uprv_malloc(size_t s) { | |
| 26 #endif | |
| 27 #endif | |
| 28 if (s > 0) { | |
| 29 - gHeapInUse = TRUE; | |
| 30 if (pAlloc) { | |
| 31 return (*pAlloc)(pContext, s); | |
| 32 } else { | |
| 33 @@ -105,7 +100,6 @@ uprv_realloc(void * buffer, size_t size) { | |
| 34 } | |
| 35 return (void *)zeroMem; | |
| 36 } else { | |
| 37 - gHeapInUse = TRUE; | |
| 38 if (pRealloc) { | |
| 39 return (*pRealloc)(pContext, buffer, size); | |
| 40 } else { | |
| 41 @@ -150,10 +144,6 @@ u_setMemoryFunctions(const void *context, UMemAllocFn *a, U
MemReallocFn *r, UMem | |
| 42 *status = U_ILLEGAL_ARGUMENT_ERROR; | |
| 43 return; | |
| 44 } | |
| 45 - if (gHeapInUse) { | |
| 46 - *status = U_INVALID_STATE_ERROR; | |
| 47 - return; | |
| 48 - } | |
| 49 pContext = context; | |
| 50 pAlloc = a; | |
| 51 pRealloc = r; | |
| 52 @@ -166,18 +156,5 @@ U_CFUNC UBool cmemory_cleanup(void) { | |
| 53 pAlloc = NULL; | |
| 54 pRealloc = NULL; | |
| 55 pFree = NULL; | |
| 56 - gHeapInUse = FALSE; | |
| 57 return TRUE; | |
| 58 } | |
| 59 - | |
| 60 - | |
| 61 -/* | |
| 62 - * gHeapInUse | |
| 63 - * Return True if ICU has allocated any memory. | |
| 64 - * Used by u_SetMutexFunctions() and similar to verify that ICU has not | |
| 65 - * been used, that it is in a pristine initial state. | |
| 66 - */ | |
| 67 -U_CFUNC UBool cmemory_inUse() { | |
| 68 - return gHeapInUse; | |
| 69 -} | |
| 70 - | |
| 71 diff --git a/source/common/cmemory.h b/source/common/cmemory.h | |
| 72 index ed29b63..d182b5a 100644 | |
| 73 --- a/source/common/cmemory.h | |
| 74 +++ b/source/common/cmemory.h | |
| 75 @@ -1,7 +1,7 @@ | |
| 76 /* | |
| 77 ****************************************************************************** | |
| 78 * | |
| 79 -* Copyright (C) 1997-2014, International Business Machines | |
| 80 +* Copyright (C) 1997-2015, International Business Machines | |
| 81 * Corporation and others. All Rights Reserved. | |
| 82 * | |
| 83 ****************************************************************************** | |
| 84 @@ -116,13 +116,6 @@ typedef union { | |
| 85 #define U_ALIGNMENT_OFFSET_UP(ptr) (sizeof(UAlignedMemory) - U_ALIGNMENT_OFFSET
(ptr)) | |
| 86 | |
| 87 /** | |
| 88 - * Indicate whether the ICU allocation functions have been used. | |
| 89 - * This is used to determine whether ICU is in an initial, unused state. | |
| 90 - */ | |
| 91 -U_CFUNC UBool | |
| 92 -cmemory_inUse(void); | |
| 93 - | |
| 94 -/** | |
| 95 * Heap clean up function, called from u_cleanup() | |
| 96 * Clears any user heap functions from u_setMemoryFunctions() | |
| 97 * Does NOT deallocate any remaining allocated memory. | |
| 98 diff --git a/source/common/icuplug.cpp b/source/common/icuplug.cpp | |
| 99 index 135eb92..2764ea5 100644 | |
| 100 --- a/source/common/icuplug.cpp | |
| 101 +++ b/source/common/icuplug.cpp | |
| 102 @@ -1,7 +1,7 @@ | |
| 103 /* | |
| 104 ****************************************************************************** | |
| 105 * | |
| 106 -* Copyright (C) 2009-2014, International Business Machines | |
| 107 +* Copyright (C) 2009-2015, International Business Machines | |
| 108 * Corporation and others. All Rights Reserved. | |
| 109 * | |
| 110 ****************************************************************************** | |
| 111 @@ -618,12 +618,10 @@ uplug_loadPlugFromLibrary(const char *libName, const char
*sym, const char *conf | |
| 112 | |
| 113 #endif | |
| 114 | |
| 115 +static UPlugLevel gCurrentLevel = UPLUG_LEVEL_LOW; | |
| 116 + | |
| 117 U_CAPI UPlugLevel U_EXPORT2 uplug_getCurrentLevel() { | |
| 118 - if(cmemory_inUse()) { | |
| 119 - return UPLUG_LEVEL_HIGH; | |
| 120 - } else { | |
| 121 - return UPLUG_LEVEL_LOW; | |
| 122 - } | |
| 123 + return gCurrentLevel; | |
| 124 } | |
| 125 | |
| 126 static UBool U_CALLCONV uplug_cleanup(void) | |
| 127 @@ -639,6 +637,7 @@ static UBool U_CALLCONV uplug_cleanup(void) | |
| 128 uplug_doUnloadPlug(pluginToRemove, &subStatus); | |
| 129 } | |
| 130 /* close other held libs? */ | |
| 131 + gCurrentLevel = UPLUG_LEVEL_LOW; | |
| 132 return TRUE; | |
| 133 } | |
| 134 | |
| 135 @@ -710,6 +709,8 @@ uplug_getPluginFile() { | |
| 136 } | |
| 137 | |
| 138 | |
| 139 +// uplug_init() is called first thing from u_init(). | |
| 140 + | |
| 141 U_CAPI void U_EXPORT2 | |
| 142 uplug_init(UErrorCode *status) { | |
| 143 #if !U_ENABLE_DYLOAD | |
| 144 @@ -866,5 +867,6 @@ uplug_init(UErrorCode *status) { | |
| 145 } | |
| 146 uplug_loadWaitingPlugs(status); | |
| 147 #endif /* U_ENABLE_DYLOAD */ | |
| 148 + gCurrentLevel = UPLUG_LEVEL_HIGH; | |
| 149 ucln_registerCleanup(UCLN_UPLUG, uplug_cleanup); | |
| 150 } | |
| 151 diff --git a/source/test/cintltst/hpmufn.c b/source/test/cintltst/hpmufn.c | |
| 152 index a0e2aa1..edb7a98 100644 | |
| 153 --- a/source/test/cintltst/hpmufn.c | |
| 154 +++ b/source/test/cintltst/hpmufn.c | |
| 155 @@ -1,6 +1,6 @@ | |
| 156 /******************************************************************** | |
| 157 * COPYRIGHT: | |
| 158 - * Copyright (c) 2003-2013, International Business Machines Corporation and | |
| 159 + * Copyright (c) 2003-2015, International Business Machines Corporation and | |
| 160 * others. All Rights Reserved. | |
| 161 ********************************************************************/ | |
| 162 /* | |
| 163 @@ -129,10 +129,6 @@ static void TestHeapFunctions() { | |
| 164 * probably because some earlier test accidently left something open. */ | |
| 165 ctest_resetICU(); | |
| 166 | |
| 167 - /* Can not set memory functions if ICU is already initialized */ | |
| 168 - u_setMemoryFunctions(&gContext, myMemAlloc, myMemRealloc, myMemFree, &statu
s); | |
| 169 - TEST_STATUS(status, U_INVALID_STATE_ERROR); | |
| 170 - | |
| 171 /* Un-initialize ICU */ | |
| 172 u_cleanup(); | |
| 173 | |
| 174 @@ -155,13 +151,11 @@ static void TestHeapFunctions() { | |
| 175 TEST_STATUS(status, U_ZERO_ERROR); | |
| 176 | |
| 177 | |
| 178 - /* After reinitializing ICU, we should not be able to set the memory funcs
again. */ | |
| 179 + /* After reinitializing ICU, we can not set the memory funcs again. */ | |
| 180 status = U_ZERO_ERROR; | |
| 181 u_setDataDirectory(icuDataDir); | |
| 182 u_init(&status); | |
| 183 TEST_STATUS(status, U_ZERO_ERROR); | |
| 184 - u_setMemoryFunctions(NULL, myMemAlloc, myMemRealloc, myMemFree, &status); | |
| 185 - TEST_STATUS(status, U_INVALID_STATE_ERROR); | |
| 186 | |
| 187 /* Doing ICU operations should cause allocations to come through our test h
eap */ | |
| 188 gBlockCount = 0; | |
| OLD | NEW |