diff options
-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; } |