openMSX
StringStorage.hh
Go to the documentation of this file.
1 #ifndef STRINGSTORAGE_HH
2 #define STRINGSTORAGE_HH
3 
4 #include <cstdlib>
5 #include <memory>
6 
12 {
13  void operator()(char* p) { free(p); }
14 };
15 using StringStorage = std::unique_ptr<char, FreeStringStorage>;
16 
17 
21 {
22  return StringStorage(static_cast<char*>(malloc(size)));
23 }
24 
25 #endif
std::unique_ptr< char, FreeStringStorage > StringStorage
StringStorage allocate_string_storage(size_t size)
Allocate a 'StringStorage' large enough for 'size' characters.
size_t size(std::string_view utf8)
StringStorage: Acts like a 'const char*', but in addition calls free() when the pointer goes out of s...
void operator()(char *p)