--- a/toolsandutils/e32tools/elf2e32/source/pagedcompress.cpp Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/pagedcompress.cpp Tue Jul 06 16:56:48 2010 +0100
@@ -270,26 +270,32 @@
}
-void CompressPages(TUint8* bytes, TInt size, std::ofstream& os)
+void CompressPages(TUint8 * bytes, TInt size, std::ofstream& os)
{
// Build a list of compressed pages
- TUint16 numOfPages = (TUint16) ((size + PAGE_SIZE - 1) / PAGE_SIZE);
+ TUint16 numOfPages = (TUint16) (size / PAGE_SIZE);
+ if ( size % PAGE_SIZE > 0)
+ ++numOfPages;
- CBytePairCompressedImage* comprImage = CBytePairCompressedImage::NewLC(numOfPages, size);
- if (!comprImage)
+ CBytePairCompressedImage *comprImage = CBytePairCompressedImage::NewLC(numOfPages, size);
+ if( NULL == comprImage)
{
//Print(EError," NULL == comprImage\n");
return;
}
- TUint pageNum;
- TUint remain = (TUint)size;
- for (pageNum=0; pageNum<numOfPages; ++pageNum)
+ TUint8* iPageStart;
+ TUint16 iPageLen;
+ TUint16 iPage = 0;
+
+ while(iPage * PAGE_SIZE <= size )
{
- TUint8* pageStart = bytes + pageNum * PAGE_SIZE;
- TUint pageLen = remain>PAGE_SIZE ? PAGE_SIZE : remain;
- comprImage->AddPage((TUint16)pageNum, pageStart, (TUint16)pageLen);
- remain -= pageLen;
+ iPageStart = &bytes[iPage * PAGE_SIZE];
+ iPageLen = (TUint16)( (iPage + 1) * PAGE_SIZE < size ? PAGE_SIZE : size - iPage * PAGE_SIZE);
+
+ comprImage->AddPage(iPage, iPageStart, iPageLen);
+
+ ++iPage;
}
// Write out index table and compressed pages
@@ -301,7 +307,6 @@
}
-
int DecompressPages(TUint8 * bytes, std::ifstream& is)
{
TUint decompressedSize = 0;