diff -r c7c26511138f -r 360bd6b35136 e32tools/elf2e32/source/pagedcompress.cpp --- a/e32tools/elf2e32/source/pagedcompress.cpp Wed Jun 16 16:51:40 2010 +0300 +++ b/e32tools/elf2e32/source/pagedcompress.cpp Wed Jun 23 16:56:47 2010 +0800 @@ -270,32 +270,26 @@ } -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); - if ( size % PAGE_SIZE > 0) - ++numOfPages; + TUint16 numOfPages = (TUint16) ((size + PAGE_SIZE - 1) / PAGE_SIZE); - CBytePairCompressedImage *comprImage = CBytePairCompressedImage::NewLC(numOfPages, size); - if( NULL == comprImage) + CBytePairCompressedImage* comprImage = CBytePairCompressedImage::NewLC(numOfPages, size); + if (!comprImage) { //Print(EError," NULL == comprImage\n"); return; } - TUint8* iPageStart; - TUint16 iPageLen; - TUint16 iPage = 0; - - while(iPage * PAGE_SIZE <= size ) + TUint pageNum; + TUint remain = (TUint)size; + for (pageNum=0; pageNumAddPage(iPage, iPageStart, iPageLen); - - ++iPage; + TUint8* pageStart = bytes + pageNum * PAGE_SIZE; + TUint pageLen = remain>PAGE_SIZE ? PAGE_SIZE : remain; + comprImage->AddPage((TUint16)pageNum, pageStart, (TUint16)pageLen); + remain -= pageLen; } // Write out index table and compressed pages @@ -307,6 +301,7 @@ } + int DecompressPages(TUint8 * bytes, std::ifstream& is) { TUint decompressedSize = 0;