diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-09-03 14:36:15 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-09-03 14:36:15 (GMT) |
commit | f0844f9da7a834c282f6f04b2676f28de444e9dc (patch) | |
tree | 8e121429e25959043cc04c4364adbe8239e44a67 /tests/auto/exceptionsafety_objects/oomsimulator.h | |
parent | fe763ef6cd255ccb54d0de1894c1a772f959585e (diff) | |
parent | f360180890298618ef3284c08789c2a243e1ba9d (diff) | |
download | Qt-f0844f9da7a834c282f6f04b2676f28de444e9dc.zip Qt-f0844f9da7a834c282f6f04b2676f28de444e9dc.tar.gz Qt-f0844f9da7a834c282f6f04b2676f28de444e9dc.tar.bz2 |
Merge commit 'qt/4.6' into kinetic-declarativeui
Diffstat (limited to 'tests/auto/exceptionsafety_objects/oomsimulator.h')
-rw-r--r-- | tests/auto/exceptionsafety_objects/oomsimulator.h | 81 |
1 files changed, 76 insertions, 5 deletions
diff --git a/tests/auto/exceptionsafety_objects/oomsimulator.h b/tests/auto/exceptionsafety_objects/oomsimulator.h index 8358fea..9432a5b 100644 --- a/tests/auto/exceptionsafety_objects/oomsimulator.h +++ b/tests/auto/exceptionsafety_objects/oomsimulator.h @@ -189,6 +189,82 @@ static struct QCrtDebugRegistrator } crtDebugRegistrator; +#elif defined(Q_OS_SYMBIAN) + +struct QAllocFailAllocator : public RAllocator +{ + QAllocFailAllocator() : allocator(User::Allocator()) + { + User::SwitchAllocator(this); + } + + ~QAllocFailAllocator() + { + User::SwitchAllocator(&allocator); + } + + RAllocator& allocator; + + // from MAllocator + TAny* Alloc(TInt aSize) + { + ++mallocCount; + if (mallocFailActive && --mallocFailIndex < 0) + return 0; // simulate OOM + return allocator.Alloc(aSize); + } + + void Free(TAny* aPtr) + { + allocator.Free(aPtr); + } + + TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode) + { + ++mallocCount; + if (mallocFailActive && --mallocFailIndex < 0) + return 0; // simulate OOM + return allocator.ReAlloc(aPtr, aSize, aMode); + } + + TInt AllocLen(const TAny* aCell) const + { + return allocator.AllocLen(aCell); + } + + TInt Compress() + { + return allocator.Compress(); + } + + void Reset() + { + allocator.Reset(); + } + + TInt AllocSize(TInt& aTotalAllocSize) const + { + return allocator.AllocSize(aTotalAllocSize); + } + + TInt Available(TInt& aBiggestBlock) const + { + return allocator.Available(aBiggestBlock); + } + + TInt DebugFunction(TInt aFunc, TAny* a1, TAny* a2) + { + return allocator.DebugFunction(aFunc, a1, a2); + } + + TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1) + { + return ((MAllocator&)allocator).Extension_(aExtensionId, a0, a1); + } +}; + +QAllocFailAllocator symbianTestAllocator; + #endif struct AllocFailer @@ -201,9 +277,6 @@ struct AllocFailer #ifdef RUNNING_ON_VALGRIND if (RUNNING_ON_VALGRIND) VALGRIND_ENABLE_OOM_AT_ALLOC_INDEX(VALGRIND_GET_ALLOC_INDEX + index + 1); -#elif defined(Q_OS_SYMBIAN) - // symbian alloc fail index is 1 based - __UHEAP_BURSTFAILNEXT(index+1, KMaxTUint16); #endif mallocFailIndex = index; mallocFailActive = true; @@ -214,8 +287,6 @@ struct AllocFailer mallocFailActive = false; #ifdef RUNNING_ON_VALGRIND VALGRIND_ENABLE_OOM_AT_ALLOC_INDEX(0); -#elif defined(Q_OS_SYMBIAN) - __UHEAP_RESET; #endif } |