| 270 | } |
| 271 | |
| 272 | char * ConstStringAllocator::impl_allocateString ( const char * text, uint64_t length ) { |
| 273 | if ( length ) { |
| 274 | // ConstStringAllocator only stores interned strings; the StrHashEntry |
| 275 | // length field caps at uint32. Const strings >4GB are pathological. |
| 276 | DAS_ASSERTF(length <= UINT32_MAX, "ConstStringAllocator caps at 4GB string length, got %llu", (unsigned long long)length); |
| 277 | if ( text ) { |
| 278 | auto it = internMap.find(StrHashEntry(text,uint32_t(length))); |
| 279 | if ( it != internMap.end() ) { |
| 280 | return (char *) it->ptr; |
| 281 | } |
| 282 | } |
| 283 | if ( auto str = (char *)allocate(length + 1) ) { |
| 284 | if ( text ) memcpy(str, text, length); |
| 285 | str[length] = 0; |
| 286 | internMap.insert(StrHashEntry(str,uint32_t(length))); |
| 287 | return str; |
| 288 | } |
| 289 | } |
| 290 | return nullptr; |
| 291 | } |
| 292 | |
| 293 | char * StringHeapAllocator::impl_allocateString ( Context * context, const char * text, uint64_t length, const LineInfo * at ) { |
| 294 | if ( length ) { |
no test coverage detected