| 33 | } |
| 34 | |
| 35 | static StringNode* create(size_t length, Allocator* allocator) { |
| 36 | if (length > maxLength) |
| 37 | return nullptr; |
| 38 | auto size = sizeForLength(length); |
| 39 | if (size < length) // integer overflow |
| 40 | return nullptr; // (not testable on 64-bit) |
| 41 | auto node = reinterpret_cast<StringNode*>(allocator->allocate(size)); |
| 42 | if (node) { |
| 43 | node->length = length_type(length); |
| 44 | node->references = 1; |
| 45 | } |
| 46 | return node; |
| 47 | } |
| 48 | |
| 49 | static StringNode* resize(StringNode* node, size_t length, |
| 50 | Allocator* allocator) { |
no test coverage detected