/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2010, International Business Machines Corporation and
+ * Copyright (c) 1997-2012, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
# include <console.h>
#endif
+#define CTST_MAX_ALLOC 8192
+/* Array used as a queue */
+static void * ctst_allocated_stuff[CTST_MAX_ALLOC] = {0};
+static int ctst_allocated = 0;
+static UBool ctst_free = FALSE;
+static int ctst_allocated_total = 0;
+
#define CTST_LEAK_CHECK 1
+
#ifdef CTST_LEAK_CHECK
-U_CFUNC void ctst_freeAll(void);
+static void ctst_freeAll(void);
#endif
static char* _testDataPath=NULL;
ctst_freeAll();
/* To check for leaks */
u_cleanup(); /* nuke the hashtable.. so that any still-open cnvs are leaked */
+
+ if(getTestOption(VERBOSITY_OPTION) && ctst_allocated_total>0) {
+ fprintf(stderr,"ctst_freeAll(): cleaned up after %d allocations (queue of %d)\n", ctst_allocated_total, CTST_MAX_ALLOC);
+ }
#ifdef URES_DEBUG
if(ures_dumpCacheContents()) {
fprintf(stderr, "Error: After final u_cleanup, RB cache was not empty.\n");
const void *p;
UErrorCode errorCode = U_ZERO_ERROR;
#if U_CHARSET_FAMILY==U_EBCDIC_FAMILY
-# ifdef OS390
+# if U_PLATFORM == U_PF_OS390
static const char convName[] = "ibm-1047";
# else
static const char convName[] = "ibm-37";
#endif
}
-#define CTST_MAX_ALLOC 8192
-/* Array used as a queue */
-static void * ctst_allocated_stuff[CTST_MAX_ALLOC] = {0};
-static int ctst_allocated = 0;
-static UBool ctst_free = FALSE;
void *ctst_malloc(size_t size) {
+ ctst_allocated_total++;
if(ctst_allocated >= CTST_MAX_ALLOC - 1) {
ctst_allocated = 0;
ctst_free = TRUE;
}
#ifdef CTST_LEAK_CHECK
-void ctst_freeAll() {
+static void ctst_freeAll() {
int i;
- if(ctst_free == 0) {
+ if(ctst_free == FALSE) { /* only free up to the allocated mark */
for(i=0; i<ctst_allocated; i++) {
free(ctst_allocated_stuff[i]);
ctst_allocated_stuff[i] = NULL;
}
- } else {
+ } else { /* free all */
for(i=0; i<CTST_MAX_ALLOC; i++) {
free(ctst_allocated_stuff[i]);
ctst_allocated_stuff[i] = NULL;
*--------------------------------------------------------------------
*/
-U_CFUNC UBool isICUVersionAtLeast(const UVersionInfo x) {
- UVersionInfo v;
- u_getVersion(v);
- return (uprv_memcmp(v, x, U_MAX_VERSION_LENGTH) >= 0);
+U_CFUNC UBool isICUVersionBefore(int major, int minor, int milli) {
+ UVersionInfo iv;
+ UVersionInfo ov;
+ ov[0] = (uint8_t)major;
+ ov[1] = (uint8_t)minor;
+ ov[2] = (uint8_t)milli;
+ ov[3] = 0;
+ u_getVersion(iv);
+ return uprv_memcmp(iv, ov, U_MAX_VERSION_LENGTH) < 0;
+}
+
+U_CFUNC UBool isICUVersionAtLeast(int major, int minor, int milli) {
+ return !isICUVersionBefore(major, minor, milli);
}
+
#endif