mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 06:25:30 +00:00
ICU-11538 Remove gHeapInUse flag.
X-SVN-Rev: 37097
This commit is contained in:
parent
1ecb2eb325
commit
fb24cef93d
4 changed files with 12 additions and 42 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-2012, International Business Machines
|
||||
* Copyright (C) 2002-2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
|
@ -78,7 +78,6 @@ uprv_malloc(size_t s) {
|
|||
#endif
|
||||
#endif
|
||||
if (s > 0) {
|
||||
gHeapInUse = TRUE;
|
||||
if (pAlloc) {
|
||||
return (*pAlloc)(pContext, s);
|
||||
} else {
|
||||
|
@ -105,7 +104,6 @@ uprv_realloc(void * buffer, size_t size) {
|
|||
}
|
||||
return (void *)zeroMem;
|
||||
} else {
|
||||
gHeapInUse = TRUE;
|
||||
if (pRealloc) {
|
||||
return (*pRealloc)(pContext, buffer, size);
|
||||
} else {
|
||||
|
@ -150,10 +148,6 @@ u_setMemoryFunctions(const void *context, UMemAllocFn *a, UMemReallocFn *r, UMem
|
|||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
if (gHeapInUse) {
|
||||
*status = U_INVALID_STATE_ERROR;
|
||||
return;
|
||||
}
|
||||
pContext = context;
|
||||
pAlloc = a;
|
||||
pRealloc = r;
|
||||
|
@ -166,18 +160,5 @@ U_CFUNC UBool cmemory_cleanup(void) {
|
|||
pAlloc = NULL;
|
||||
pRealloc = NULL;
|
||||
pFree = NULL;
|
||||
gHeapInUse = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* gHeapInUse
|
||||
* Return True if ICU has allocated any memory.
|
||||
* Used by u_SetMutexFunctions() and similar to verify that ICU has not
|
||||
* been used, that it is in a pristine initial state.
|
||||
*/
|
||||
U_CFUNC UBool cmemory_inUse() {
|
||||
return gHeapInUse;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Copyright (C) 1997-2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
|
@ -115,13 +115,6 @@ typedef union {
|
|||
*/
|
||||
#define U_ALIGNMENT_OFFSET_UP(ptr) (sizeof(UAlignedMemory) - U_ALIGNMENT_OFFSET(ptr))
|
||||
|
||||
/**
|
||||
* Indicate whether the ICU allocation functions have been used.
|
||||
* This is used to determine whether ICU is in an initial, unused state.
|
||||
*/
|
||||
U_CFUNC UBool
|
||||
cmemory_inUse(void);
|
||||
|
||||
/**
|
||||
* Heap clean up function, called from u_cleanup()
|
||||
* Clears any user heap functions from u_setMemoryFunctions()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2014, International Business Machines
|
||||
* Copyright (C) 2009-2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
|
@ -618,12 +618,10 @@ uplug_loadPlugFromLibrary(const char *libName, const char *sym, const char *conf
|
|||
|
||||
#endif
|
||||
|
||||
static UPlugLevel gCurrentLevel = UPLUG_LEVEL_LOW;
|
||||
|
||||
U_CAPI UPlugLevel U_EXPORT2 uplug_getCurrentLevel() {
|
||||
if(cmemory_inUse()) {
|
||||
return UPLUG_LEVEL_HIGH;
|
||||
} else {
|
||||
return UPLUG_LEVEL_LOW;
|
||||
}
|
||||
return gCurrentLevel;
|
||||
}
|
||||
|
||||
static UBool U_CALLCONV uplug_cleanup(void)
|
||||
|
@ -639,6 +637,7 @@ static UBool U_CALLCONV uplug_cleanup(void)
|
|||
uplug_doUnloadPlug(pluginToRemove, &subStatus);
|
||||
}
|
||||
/* close other held libs? */
|
||||
gCurrentLevel = UPLUG_LEVEL_LOW;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -710,6 +709,8 @@ uplug_getPluginFile() {
|
|||
}
|
||||
|
||||
|
||||
// uplug_init() is called first thing from u_init().
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
uplug_init(UErrorCode *status) {
|
||||
#if !U_ENABLE_DYLOAD
|
||||
|
@ -866,5 +867,6 @@ uplug_init(UErrorCode *status) {
|
|||
}
|
||||
uplug_loadWaitingPlugs(status);
|
||||
#endif /* U_ENABLE_DYLOAD */
|
||||
gCurrentLevel = UPLUG_LEVEL_HIGH;
|
||||
ucln_registerCleanup(UCLN_UPLUG, uplug_cleanup);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 2003-2013, International Business Machines Corporation and
|
||||
* Copyright (c) 2003-2015, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/*
|
||||
|
@ -129,10 +129,6 @@ static void TestHeapFunctions() {
|
|||
* probably because some earlier test accidently left something open. */
|
||||
ctest_resetICU();
|
||||
|
||||
/* Can not set memory functions if ICU is already initialized */
|
||||
u_setMemoryFunctions(&gContext, myMemAlloc, myMemRealloc, myMemFree, &status);
|
||||
TEST_STATUS(status, U_INVALID_STATE_ERROR);
|
||||
|
||||
/* Un-initialize ICU */
|
||||
u_cleanup();
|
||||
|
||||
|
@ -155,13 +151,11 @@ static void TestHeapFunctions() {
|
|||
TEST_STATUS(status, U_ZERO_ERROR);
|
||||
|
||||
|
||||
/* After reinitializing ICU, we should not be able to set the memory funcs again. */
|
||||
/* After reinitializing ICU, we can not set the memory funcs again. */
|
||||
status = U_ZERO_ERROR;
|
||||
u_setDataDirectory(icuDataDir);
|
||||
u_init(&status);
|
||||
TEST_STATUS(status, U_ZERO_ERROR);
|
||||
u_setMemoryFunctions(NULL, myMemAlloc, myMemRealloc, myMemFree, &status);
|
||||
TEST_STATUS(status, U_INVALID_STATE_ERROR);
|
||||
|
||||
/* Doing ICU operations should cause allocations to come through our test heap */
|
||||
gBlockCount = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue