diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-02-23 20:39:56 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-02-23 20:39:56 +0000 |
| commit | 0a6901899d844a51ddda3727b587736055b65857 (patch) | |
| tree | a522f687a95cf5ed024af9ab544deac6bb6b83f0 /src/shared_string.hh | |
| parent | 37a14032956003c6301ff862053e90cbd153ef2c (diff) | |
Use RefPtr as SafePtr backend
Diffstat (limited to 'src/shared_string.hh')
| -rw-r--r-- | src/shared_string.hh | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/shared_string.hh b/src/shared_string.hh index a73f8dd2..8af9820c 100644 --- a/src/shared_string.hh +++ b/src/shared_string.hh @@ -21,7 +21,7 @@ struct StringStorage : UseMemoryDomain<MemoryDomain::SharedString> [[gnu::always_inline]] StringView strview() const { return {data(), length}; } - static StringStorage* create(StringView str, char back = 0) + static RefPtr<StringStorage> create(StringView str, char back = 0) { const int len = (int)str.length() + (back != 0 ? 1 : 0); void* ptr = StringStorage::operator new(sizeof(StringStorage) + len + 1); @@ -32,7 +32,7 @@ struct StringStorage : UseMemoryDomain<MemoryDomain::SharedString> if (back != 0) res->data()[len-1] = back; res->data()[len] = 0; - return res; + return RefPtr<StringStorage>(res); } static void destroy(StringStorage* s) @@ -40,8 +40,8 @@ struct StringStorage : UseMemoryDomain<MemoryDomain::SharedString> StringStorage::operator delete(s, sizeof(StringStorage) + s->length + 1); } - friend void inc_ref_count(StringStorage* s) { ++s->refcount; } - friend void dec_ref_count(StringStorage* s) { if (--s->refcount == 0) StringStorage::destroy(s); } + friend void inc_ref_count(StringStorage* s, void*) { ++s->refcount; } + friend void dec_ref_count(StringStorage* s, void*) { if (--s->refcount == 0) StringStorage::destroy(s); } }; inline RefPtr<StringStorage> operator"" _ss(const char* ptr, size_t len) |
