Closed minggo closed 2 years ago
inline StringHandle StringPool<ThreadSafe>::doStringToHandle(const char *str) noexcept { const auto it = _stringToHandles.find(str); if (it == _stringToHandles.end()) { size_t const strLength = strlen(str) + 1; char *const strCache = new char[strLength]; // memory leak: create memory, but do't find anywhere to free the memory strcpy(strCache, str); StringHandle name(static_cast<StringHandle::IndexType>(_handleToStrings.size()), strCache); _handleToStrings.emplace_back(strCache); _stringToHandles.emplace(strCache, name); return name; } return it->second; }
Currently, StringPool is used in FrameGraph. Maybe can use ccstd::string instead?
Oh, the memory is freed in destructor.
Currently, StringPool is used in FrameGraph. Maybe can use ccstd::string instead?