/*
******************************************************************************
*
-* Copyright (C) 2002-2012, International Business Machines
+* Copyright (C) 2002-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
#endif
#endif
if (s > 0) {
- gHeapInUse = TRUE;
if (pAlloc) {
return (*pAlloc)(pContext, s);
} else {
}
return (void *)zeroMem;
} else {
- gHeapInUse = TRUE;
if (pRealloc) {
return (*pRealloc)(pContext, buffer, size);
} else {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
- if (gHeapInUse) {
- *status = U_INVALID_STATE_ERROR;
- return;
- }
pContext = context;
pAlloc = a;
pRealloc = r;
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;
-}
-
/*
******************************************************************************
*
-* Copyright (C) 1997-2014, International Business Machines
+* Copyright (C) 1997-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
*/
#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()
/*
******************************************************************************
*
-* Copyright (C) 2009-2014, International Business Machines
+* Copyright (C) 2009-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
#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)
uplug_doUnloadPlug(pluginToRemove, &subStatus);
}
/* close other held libs? */
+ gCurrentLevel = UPLUG_LEVEL_LOW;
return TRUE;
}
}
+// uplug_init() is called first thing from u_init().
+
U_CAPI void U_EXPORT2
uplug_init(UErrorCode *status) {
#if !U_ENABLE_DYLOAD
}
uplug_loadWaitingPlugs(status);
#endif /* U_ENABLE_DYLOAD */
+ gCurrentLevel = UPLUG_LEVEL_HIGH;
ucln_registerCleanup(UCLN_UPLUG, uplug_cleanup);
}
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2003-2013, International Business Machines Corporation and
+ * Copyright (c) 2003-2015, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
* 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();
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;