Changeset 0860d9c for libcfa/src/collections/string_res.cfa
- Timestamp:
- Oct 5, 2023, 4:17:14 PM (12 months ago)
- Branches:
- master
- Children:
- 4d860ea3
- Parents:
- b67b632
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/string_res.cfa
rb67b632 r0860d9c 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 (;;) { 220 for (bool cont = true; cont; ) { 221 cont = false; 222 221 223 // Append dummy content to temp, forcing expansion when applicable (occurs always on subsequent loops) 222 224 // length 2 ensures room for at least one real char, plus scanf/pipe-cstr's null terminator … … 228 230 temp.Handle.ulink->EndVbyte -= 2; 229 231 230 // rest of heap , less 1 byte for null terminator,is available to read into231 int lenReadable = (char*)temp.Handle.ulink->ExtVbyte - temp.Handle.ulink->EndVbyte - 1;232 assert (lenReadable >= 1);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); 233 235 234 236 // get bytes 235 in | wdi( lenReadable + 1, lenReadable, temp.Handle.ulink->EndVbyte ); 237 try { 238 in | wdi( lenReadable, temp.Handle.ulink->EndVbyte ); 239 } catch (cstring_length*) { 240 cont = true; 241 } 236 242 int lenWasRead = strlen(temp.Handle.ulink->EndVbyte); 237 243 … … 239 245 temp.Handle.lnth += lenWasRead; 240 246 temp.Handle.ulink->EndVbyte += lenWasRead; 241 242 if (lenWasRead < lenReadable) break;243 247 } 244 248
Note: See TracChangeset
for help on using the changeset viewer.