diff options
Diffstat (limited to 'src/slices.c')
-rwxr-xr-x | src/slices.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/slices.c b/src/slices.c index 8e9aee6..68e39f9 100755 --- a/src/slices.c +++ b/src/slices.c @@ -113,14 +113,43 @@ slice_t *slicesFindLargest(slices_t *slices, sliceStatus_t status) { return sMax; } +slice_t *slicesFindLargestFast(slices_t *slices, address_t *foundMax, sliceStatus_t status, address_t knownMax, slice_t *firstToTry) { + slice_t *curr, *sMax = NULL; + address_t i, iMax = 0; + + curr = firstToTry; + while (curr != NULL) { + i=curr->end - curr->begin + 1; + if ( curr->status == status ) { + if ( knownMax == i ) { *foundMax=i; return curr; } + if ( i > iMax ) { + iMax = i; + sMax = curr; + } + } + curr=curr->next; + } + curr = slices->first; + while (curr != firstToTry) { + i=curr->end - curr->begin + 1; + if ( curr->status == status && i > iMax ) { + iMax = i; + sMax = curr; + } + curr=curr->next; + } + *foundMax=iMax; + return sMax; +} + char *slicesDump(slices_t *slices, address_t *blockSize, unsigned int charCount, address_t begin, address_t end) { slice_t *curr = slices->first; - unsigned int sb,se,i; + address_t sb,se,i; char *dump, ci; // If blockSize is 0, try to autodetect to display entire slice chain if (*blockSize == 0) { - *blockSize=(end-begin+1)/(charCount+1); + *blockSize=(end-begin+1)/(charCount-1); // If we have a too big zoom factor, draw it at 1:1 scale if (*blockSize==0) *blockSize=1; } @@ -132,6 +161,11 @@ char *slicesDump(slices_t *slices, address_t *blockSize, unsigned int charCount, while (curr != NULL) { sb=curr->begin / *blockSize; //FIXME : gérer le max également ! +/* +if ( curr->end / *blockSize > charCount -1 ) { + printf("\nBUG : end/blkSze==%lli, charCount==%i\n", curr->end / *blockSize,charCount-1); +} +*/ se=min(curr->end / *blockSize,charCount-1); switch (curr->status) { |