diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-01-12 13:24:30 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-01-12 13:32:14 +0000 |
| commit | 0bdf1778cb60338abbbaf9fbdac3e5a983304448 (patch) | |
| tree | bf197aeb94d1e8eec01dd656dd8ef125390e40ac /src/option_manager.hh | |
| parent | dedb16bc73372eb45a24925590ecc8273e4efabf (diff) | |
Some more memory tracking
Diffstat (limited to 'src/option_manager.hh')
| -rw-r--r-- | src/option_manager.hh | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/option_manager.hh b/src/option_manager.hh index c1f9bd12..ad295fb4 100644 --- a/src/option_manager.hh +++ b/src/option_manager.hh @@ -7,6 +7,7 @@ #include "flags.hh" #include "option_types.hh" #include "regex.hh" +#include "vector.hh" namespace Kakoune { @@ -91,7 +92,7 @@ public: CandidateList complete_option_name(StringView prefix, ByteCount cursor_pos); - using OptionList = std::vector<const Option*>; + using OptionList = Vector<const Option*>; OptionList flatten_options() const; void register_watcher(OptionManagerWatcher& watcher); @@ -108,10 +109,10 @@ private: template<typename MatchingFunc> CandidateList get_matching_names(MatchingFunc func); - std::vector<std::unique_ptr<Option>> m_options; + Vector<std::unique_ptr<Option>, MemoryDomain::Options> m_options; OptionManager* m_parent; - std::vector<OptionManagerWatcher*> m_watchers; + Vector<OptionManagerWatcher*, MemoryDomain::Options> m_watchers; }; template<typename T> @@ -153,6 +154,18 @@ public: { return new TypedOption{manager, m_desc, m_value}; } + + using Alloc = Allocator<TypedOption, MemoryDomain::Options>; + static void* operator new (std::size_t sz) + { + kak_assert(sz == sizeof(TypedOption)); + return Alloc{}.allocate(1); + } + + static void operator delete (void* ptr) + { + return Alloc{}.deallocate(reinterpret_cast<TypedOption*>(ptr), 1); + } private: T m_value; }; @@ -216,7 +229,7 @@ public: } private: OptionManager& m_global_manager; - std::vector<std::unique_ptr<OptionDesc>> m_descs; + Vector<std::unique_ptr<OptionDesc>, MemoryDomain::Options> m_descs; }; } |
