summaryrefslogtreecommitdiff
path: root/src/slices.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/slices.c')
-rw-r--r--src/slices.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/slices.c b/src/slices.c
index e84facf..36f7bb1 100644
--- a/src/slices.c
+++ b/src/slices.c
@@ -214,19 +214,21 @@ char *slicesDump(slices_t *slices, address_t *blockSize, unsigned int charCount,
//For each slice
while (curr != NULL) {
- // If is (partially) contained in the [begin,end] interval
- if ( (curr->begin >= begin && curr->begin <=end) || ( curr->end >= end && curr->end <= end ) ) {
-
+ // If "curr" slice is (partially) contained/visible in the [begin,end] display interval
+ if ( !(curr->end < begin) && !(curr->begin > end) ) {
// Draw the slice on the right number of characters
- sb=MAX(0, (curr->begin - begin) / *blockSize);
+ // Mathematically correct, but crashes because address_t is UNSIGNED
+ // sb=MAX(0, (curr->begin - begin) / *blockSize);
+ sb=(curr->begin < begin)?0:(curr->begin - begin) / *blockSize;
se=MIN((curr->end - begin) / *blockSize, charCount-1);
- // Debug assertion
+ /* Debug "assertion"
if (sb >= charCount || se >= charCount) {
printf("BUG : sb==%lli, se=%lli, charCount==%i\n", sb, se, charCount);
+ printf("BUG : MAX(0, (%lli - %lli) / %lli)", curr->begin, begin, *blockSize);
pthread_mutex_unlock(&(slices->writeOrConsistentReadMutex));
exit(42);
- }
+ }*/
// Choose from the current slice status the right char to draw
switch (curr->status) {