diff options
author | Shane Kearns <shane.kearns@sosco.com> | 2009-12-03 12:47:45 (GMT) |
---|---|---|
committer | mread <qt-info@nokia.com> | 2010-09-30 14:48:26 (GMT) |
commit | 8a7b487497bb18a2f30ebeeddf82fbf0fff4cc54 (patch) | |
tree | d06c91b33ddaab5d2846a0bce84caf7546f7891e /src/corelib/arch | |
parent | c88937dfa5b13df17203c34bec39fe2e03ad8902 (diff) | |
download | Qt-8a7b487497bb18a2f30ebeeddf82fbf0fff4cc54.zip Qt-8a7b487497bb18a2f30ebeeddf82fbf0fff4cc54.tar.gz Qt-8a7b487497bb18a2f30ebeeddf82fbf0fff4cc54.tar.bz2 |
Implement RNewAllocator::Available for Doug Lea section
Task-number: QT-3967
Reviewed-by: mread
Diffstat (limited to 'src/corelib/arch')
-rw-r--r-- | src/corelib/arch/symbian/dla_p.h | 1 | ||||
-rw-r--r-- | src/corelib/arch/symbian/newallocator.cpp | 17 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/corelib/arch/symbian/dla_p.h b/src/corelib/arch/symbian/dla_p.h index 33344ef..9d31499 100644 --- a/src/corelib/arch/symbian/dla_p.h +++ b/src/corelib/arch/symbian/dla_p.h @@ -241,6 +241,7 @@ struct mallinfo { MALLINFO_FIELD_TYPE fordblks; /* total free space */ MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ MALLINFO_FIELD_TYPE cellCount;/* Number of chunks allocated*/ + MALLINFO_FIELD_TYPE largestBlock; }; #endif /* HAVE_USR_INCLUDE_MALLOC_H */ diff --git a/src/corelib/arch/symbian/newallocator.cpp b/src/corelib/arch/symbian/newallocator.cpp index 69164f9..2d4bd05 100644 --- a/src/corelib/arch/symbian/newallocator.cpp +++ b/src/corelib/arch/symbian/newallocator.cpp @@ -503,12 +503,13 @@ TAny* RNewAllocator::ReAlloc(TAny* aPtr, TInt aSize, TInt /*aMode = 0*/) TInt RNewAllocator::Available(TInt& aBiggestBlock) const { - //struct mallinfo mi = dlmallinfo(); - aBiggestBlock = 0; - //return mi.fordblks; - return ptrdiff(iTop, iBase) - iTotalAllocSize; //HACK - /*Need to see how to implement this*/ - // TODO: return iHeap.Available(aBiggestBlock); + //TODO: consider page and slab allocators + + //this gets free space in DL region - the C ported code doesn't respect const yet. + RNewAllocator* self = const_cast<RNewAllocator*> (this); + mallinfo info = self->dlmallinfo(); + aBiggestBlock = info.largestBlock; + return info.fordblks; } TInt RNewAllocator::AllocSize(TInt& aTotalAllocSize) const { @@ -812,7 +813,7 @@ void* RNewAllocator::internal_realloc(mstate m, void* oldmem, size_t bytes) } /* ----------------------------- statistics ------------------------------ */ mallinfo RNewAllocator::internal_mallinfo(mstate m) { - struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; TInt chunkCnt = 0; if (!PREACTION(m)) { check_malloc_state(m); @@ -829,6 +830,8 @@ mallinfo RNewAllocator::internal_mallinfo(mstate m) { size_t sz = chunksize(q); sum += sz; if (!cinuse(q)) { + if (sz > nm.largestBlock) + nm.largestBlock = sz; mfree += sz; ++nfree; } |