Changeset 353


Ignore:
Timestamp:
Sep 24, 2012 11:11:31 AM (7 years ago)
Author:
kulshres
Message:

check for zero blocks separately

iter=indexFree.erase(iter) advances iter to the next element, then the
for loop advances it again. So we potentially miss a block, which could
either be a tail block or a zero block. Just stop as soon as we find tail
and we remove the zero blocks after allocating the new tail block, if any
are remaining.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ADOL-C/src/tape_handling.cpp

    r352 r353  
    13341334      delete [] oldStore;
    13351335    }
     1336
    13361337    bool foundTail = false;
    13371338    list<struct FreeBlock>::iterator iter = indexFree.begin();
     
    13431344              indexFree.push_front(tmp);
    13441345              foundTail = true;
     1346              break;
    13451347         }
    1346          if (!(iter->size)) iter=indexFree.erase(iter); // don't leave 0 blocks around
    1347     }
     1348    }
     1349
    13481350    if (! foundTail) {
    13491351        struct FreeBlock tmp;
     
    13511353        tmp.size = (maxsize - oldMaxsize);
    13521354        indexFree.push_front(tmp);
     1355    }
     1356
     1357    iter = indexFree.begin();
     1358    while (iter != indexFree.end()) {
     1359         if (iter->size == 0)
     1360             iter=indexFree.erase(iter); // don't leave 0 blocks around
     1361         else
     1362             iter++;
    13531363    }
    13541364#ifdef ADOLC_DEBUG
Note: See TracChangeset for help on using the changeset viewer.