- File:
-
- 1 edited
-
libcfa/src/collections/string_res.cfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/string_res.cfa
r0860d9c r416b443 218 218 // Read in chunks. Often, one chunk is enough. Keep the string that accumulates chunks last in the heap, 219 219 // 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 (;;) { 223 221 // Append dummy content to temp, forcing expansion when applicable (occurs always on subsequent loops) 224 222 // length 2 ensures room for at least one real char, plus scanf/pipe-cstr's null terminator … … 230 228 temp.Handle.ulink->EndVbyte -= 2; 231 229 232 // rest of heap is available to read into233 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); 235 233 236 234 // 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 ); 242 236 int lenWasRead = strlen(temp.Handle.ulink->EndVbyte); 243 237 … … 245 239 temp.Handle.lnth += lenWasRead; 246 240 temp.Handle.ulink->EndVbyte += lenWasRead; 241 242 if (lenWasRead < lenReadable) break; 247 243 } 248 244
Note:
See TracChangeset
for help on using the changeset viewer.