Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/collections/string_res.cfa

    r0860d9c r416b443  
    218218    // Read in chunks.  Often, one chunk is enough.  Keep the string that accumulates chunks last in the heap,
    219219    // so available room is rest of heap.  When a chunk fills the heap, force growth then take the next chunk.
    220     for (bool cont = true; cont; ) {
    221         cont = false;
    222 
     220    for (;;) {
    223221        // Append dummy content to temp, forcing expansion when applicable (occurs always on subsequent loops)
    224222        // length 2 ensures room for at least one real char, plus scanf/pipe-cstr's null terminator
     
    230228        temp.Handle.ulink->EndVbyte -= 2;
    231229
    232         // rest of heap is available to read into
    233         int lenReadable = (char*)temp.Handle.ulink->ExtVbyte - temp.Handle.ulink->EndVbyte;
    234         assert (lenReadable >= 2);
     230        // rest of heap, less 1 byte for null terminator, is available to read into
     231        int lenReadable = (char*)temp.Handle.ulink->ExtVbyte - temp.Handle.ulink->EndVbyte - 1;
     232        assert (lenReadable >= 1);
    235233
    236234        // get bytes
    237         try {
    238             in | wdi( lenReadable, temp.Handle.ulink->EndVbyte );
    239         } catch (cstring_length*) {
    240             cont = true;
    241         }
     235        in | wdi( lenReadable + 1, lenReadable, temp.Handle.ulink->EndVbyte );
    242236        int lenWasRead = strlen(temp.Handle.ulink->EndVbyte);
    243237
     
    245239        temp.Handle.lnth += lenWasRead;
    246240        temp.Handle.ulink->EndVbyte += lenWasRead;
     241
     242      if (lenWasRead < lenReadable) break;
    247243    }
    248244
Note: See TracChangeset for help on using the changeset viewer.