- updated code to protect against null pointers and uninitialized values and threading issues

This commit is contained in:
Mark Vejvoda
2013-02-04 08:30:43 +00:00
parent d02f91d2e0
commit f87b8b6ee2
35 changed files with 332 additions and 188 deletions

View File

@@ -74,14 +74,16 @@ protected:
}
}
try {
Mutex &mutexCache = manageCachedItemMutex<T>(cacheKey);
MutexSafeWrapper safeMutex(&mutexCache);
itemCache[cacheKey] = *value;
safeMutex.ReleaseLock();
}
catch(const std::exception &ex) {
throw megaglest_runtime_error(ex.what());
if(value != NULL) {
try {
Mutex &mutexCache = manageCachedItemMutex<T>(cacheKey);
MutexSafeWrapper safeMutex(&mutexCache);
itemCache[cacheKey] = *value;
safeMutex.ReleaseLock();
}
catch(const std::exception &ex) {
throw megaglest_runtime_error(ex.what());
}
}
}
// If this is the first access we return a default object of the type

View File

@@ -212,6 +212,8 @@ typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
// 7.18.1.3 Fastest minimum-width integer types
#if (_MSC_VER < 1700)
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
@@ -221,6 +223,8 @@ typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
#endif
// 7.18.1.4 Integer types capable of holding object pointers
#ifdef _WIN64 // [
typedef signed __int64 intptr_t;