/*********************************************************
- * Copyright (C) 1998-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2016,2020 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#endif
#define NUMTABLE() HashTable_AllocOnce(&errNumTable, HASHTABLE_SIZE, \
- HASH_INT_KEY | HASH_FLAG_ATOMIC, NULL)
+ HASH_INT_KEY | HASH_FLAG_ATOMIC, \
+ ErrFreeErrInfo)
#define PTRTABLE() HashTable_AllocOnce(&errPtrTable, HASHTABLE_SIZE, \
HASH_INT_KEY | HASH_FLAG_ATOMIC, NULL)
#if defined VMX86_DEBUG && defined __linux__
#endif
+/*
+ *----------------------------------------------------------------------
+ *
+ * ErrFreeErrInfo --
+ *
+ * HashTableFreeEntryFn helper function to free ErrInfo struct.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+ErrFreeErrInfo(void *pErrInfo) // IN
+{
+ ErrInfo *errInfo = pErrInfo;
+ if (errInfo) {
+ free(errInfo->string);
+ free(errInfo);
+ }
+}
+
+
/*
*----------------------------------------------------------------------
*
*
* Results:
* Error message string in UTF-8.
- *
+ *
* Side effects:
* None.
* Current error number is preserved.
*
* Results:
* Error number or ERR_INVALID.
- *
+ *
* Side effects:
* None.
*
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * Err_Exit --
+ *
+ * Reclaim memory. Useful for avoiding leaks at exit being
+ * reported by valgrind / Memory Validator.
+ *
+ * Assumes that no other threads are calling into bora/lib/err.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+Err_Exit(void) // IN
+{
+ HashTable *numTable = NUMTABLE();
+ HashTable *ptrTable = PTRTABLE();
+#if defined VMX86_DEBUG && defined __linux__
+ HashTable *strTable = STRTABLE();
+
+ HashTable_FreeUnsafe(strTable);
+#endif
+ HashTable_FreeUnsafe(ptrTable);
+ HashTable_FreeUnsafe(numTable);
+}
+
+
#ifdef VMX86_DEBUG
/*
*----------------------------------------------------------------------
*
* Results:
* Error number or ERR_INVALID.
- *
+ *
* Side effects:
* None.
*
/*********************************************************
- * Copyright (C) 2004-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2004-2020 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
char *Err_SanitizeMessage(const char *msg);
#endif
+void Err_Exit(void);
+
/*
*----------------------------------------------------------------------
*