diff options
-rw-r--r-- | include/gras/callable.hpp | 4 | ||||
-rw-r--r-- | lib/callable.cpp | 9 |
2 files changed, 6 insertions, 7 deletions
diff --git a/include/gras/callable.hpp b/include/gras/callable.hpp index 32d6d17..6573370 100644 --- a/include/gras/callable.hpp +++ b/include/gras/callable.hpp @@ -5,8 +5,8 @@ #include <gras/gras.hpp> #include <PMC/PMC.hpp> +#include <boost/shared_ptr.hpp> #include <string> -#include <vector> namespace gras { @@ -92,7 +92,7 @@ struct GRAS_API Callable ******************************************************************/ void _register_call(const std::string &, void *); virtual PMCC _handle_call(const std::string &, const PMCC *); - void *_call_registry; + boost::shared_ptr<void> _call_registry; }; } //namespace gras diff --git a/lib/callable.cpp b/lib/callable.cpp index 6014974..cd783fc 100644 --- a/lib/callable.cpp +++ b/lib/callable.cpp @@ -11,24 +11,23 @@ typedef std::map<std::string, boost::shared_ptr<CallableRegistryEntry> > Callabl Callable::Callable(void) { - _call_registry = new CallableRegistry(); + _call_registry.reset(new CallableRegistry()); } Callable::~Callable(void) { - CallableRegistry *cr = reinterpret_cast<CallableRegistry *>(_call_registry); - delete cr; + _call_registry.reset(); } void Callable::_register_call(const std::string &key, void *entry) { - CallableRegistry *cr = reinterpret_cast<CallableRegistry *>(_call_registry); + CallableRegistry *cr = reinterpret_cast<CallableRegistry *>(_call_registry.get()); (*cr)[key].reset(reinterpret_cast<CallableRegistryEntry *>(entry)); } PMCC Callable::_handle_call(const std::string &key, const PMCC *args) { - CallableRegistry *cr = reinterpret_cast<CallableRegistry *>(_call_registry); + CallableRegistry *cr = reinterpret_cast<CallableRegistry *>(_call_registry.get()); boost::shared_ptr<CallableRegistryEntry> entry = (*cr)[key]; if (not entry) throw std::invalid_argument("Callable: no method registered for key: " + key); return entry->call(args); |