Write a string value to a STRING slot, allocating memory from 'pool'. Returns an error if memory cannot be allocated without exceeding a memory limit.
| 70 | /// Write a string value to a STRING slot, allocating memory from 'pool'. Returns |
| 71 | /// an error if memory cannot be allocated without exceeding a memory limit. |
| 72 | Status SystemTableScanner::WriteStringSlot( |
| 73 | const char* data, int len, MemPool* pool, void* slot) { |
| 74 | char* buffer = reinterpret_cast<char*>(pool->TryAllocateUnaligned(len)); |
| 75 | if (UNLIKELY(buffer == nullptr)) { |
| 76 | string details = Substitute(ERROR_MEM_LIMIT_EXCEEDED, "WriteStringSlot", len); |
| 77 | return pool->mem_tracker()->MemLimitExceeded(state_, details, len); |
| 78 | } |
| 79 | memcpy(buffer, data, len); |
| 80 | reinterpret_cast<StringValue*>(slot)->Assign(buffer, len); |
| 81 | return Status::OK(); |
| 82 | } |
| 83 | |
| 84 | Status SystemTableScanner::WriteStringSlot(const string& str, MemPool* pool, void* slot) { |
| 85 | return WriteStringSlot(str.data(), str.size(), pool, slot); |
nothing calls this directly
no test coverage detected