| 41 | } |
| 42 | |
| 43 | void StringHolder::grow(size newLength) { |
| 44 | if (newLength + 1 <= mCapacity) { |
| 45 | // We have enough capacity for newLength + null terminator |
| 46 | mLength = newLength; |
| 47 | mData[mLength] = '\0'; |
| 48 | return; |
| 49 | } |
| 50 | |
| 51 | // Use fl::realloc for efficient growth without memory move |
| 52 | // fl::realloc may expand in place or copy to larger block as needed |
| 53 | mData = (char*)fl::realloc(mData, newLength + 1); |
| 54 | mLength = newLength; |
| 55 | mCapacity = newLength + 1; |
| 56 | mData[mLength] = '\0'; // Ensure null-termination |
| 57 | } |
| 58 | |
| 59 | } // namespace fl |