From e49cb96073f514edbe1b7a9854b49c47af35463c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 12 Aug 2012 04:53:15 +0000 Subject: Fix memory leaks. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4667 a436a847-0d15-0410-975c-d299462d15a1 --- src/serialisation/Parser.cpp | 3 +++ src/server/LV2Info.cpp | 25 +++++++++++++++---------- src/server/LV2Info.hpp | 37 +++++++++++++++++++------------------ src/server/NodeFactory.cpp | 20 +++----------------- src/server/NodeFactory.hpp | 7 +++---- src/server/PortImpl.cpp | 11 ++++++----- src/server/Worker.cpp | 5 +++++ src/server/Worker.hpp | 5 +++-- 8 files changed, 57 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index 363e9c15..b8d0adbc 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -70,6 +70,8 @@ relative_uri(Glib::ustring base, const Glib::ustring uri, bool leading_slash) if (leading_slash && ret[0] != '/') ret = Glib::ustring("/") + ret; } + + serd_node_free(&normal_base_uri_node); } if (leading_slash && ret[0] != '/') { @@ -130,6 +132,7 @@ get_properties(Ingen::World* world, } } + free((uint8_t*)out.buf); sratom_free(sratom); return props; } diff --git a/src/server/LV2Info.cpp b/src/server/LV2Info.cpp index b7474b76..726dade8 100644 --- a/src/server/LV2Info.cpp +++ b/src/server/LV2Info.cpp @@ -59,17 +59,22 @@ LV2Info::LV2Info(Ingen::World* world) LV2Info::~LV2Info() { - lilv_node_free(rsz_minimumSize); - lilv_node_free(lv2_portProperty); - lilv_node_free(lv2_default); - lilv_node_free(lv2_OutputPort); - lilv_node_free(lv2_InputPort); - lilv_node_free(lv2_ControlPort); - lilv_node_free(lv2_CVPort); - lilv_node_free(lv2_AudioPort); - lilv_node_free(atom_supports); - lilv_node_free(atom_bufferType); lilv_node_free(atom_AtomPort); + lilv_node_free(atom_bufferType); + lilv_node_free(atom_supports); + lilv_node_free(lv2_AudioPort); + lilv_node_free(lv2_CVPort); + lilv_node_free(lv2_ControlPort); + lilv_node_free(lv2_InputPort); + lilv_node_free(lv2_OutputPort); + lilv_node_free(lv2_default); + lilv_node_free(lv2_portProperty); + lilv_node_free(lv2_sampleRate); + lilv_node_free(morph_AutoMorphPort); + lilv_node_free(morph_MorphPort); + lilv_node_free(morph_supportsType); + lilv_node_free(rsz_minimumSize); + lilv_node_free(work_schedule); } } // namespace Server diff --git a/src/server/LV2Info.hpp b/src/server/LV2Info.hpp index 9b6ea9db..fd70ea83 100644 --- a/src/server/LV2Info.hpp +++ b/src/server/LV2Info.hpp @@ -17,35 +17,36 @@ #ifndef INGEN_ENGINE_LV2INFO_HPP #define INGEN_ENGINE_LV2INFO_HPP -#include "lilv/lilv.h" #include "ingen/World.hpp" +#include "lilv/lilv.h" +#include "raul/Noncopyable.hpp" namespace Ingen { namespace Server { /** Stuff that may need to be passed to an LV2 plugin (i.e. LV2 features). */ -class LV2Info { +class LV2Info : public Raul::Noncopyable { public: explicit LV2Info(Ingen::World* world); ~LV2Info(); - LilvNode* atom_AtomPort; - LilvNode* atom_bufferType; - LilvNode* atom_supports; - LilvNode* lv2_AudioPort; - LilvNode* lv2_CVPort; - LilvNode* lv2_ControlPort; - LilvNode* lv2_InputPort; - LilvNode* lv2_OutputPort; - LilvNode* lv2_default; - LilvNode* lv2_portProperty; - LilvNode* lv2_sampleRate; - LilvNode* morph_AutoMorphPort; - LilvNode* morph_MorphPort; - LilvNode* morph_supportsType; - LilvNode* rsz_minimumSize; - LilvNode* work_schedule; + LilvNode* const atom_AtomPort; + LilvNode* const atom_bufferType; + LilvNode* const atom_supports; + LilvNode* const lv2_AudioPort; + LilvNode* const lv2_CVPort; + LilvNode* const lv2_ControlPort; + LilvNode* const lv2_InputPort; + LilvNode* const lv2_OutputPort; + LilvNode* const lv2_default; + LilvNode* const lv2_portProperty; + LilvNode* const lv2_sampleRate; + LilvNode* const morph_AutoMorphPort; + LilvNode* const morph_MorphPort; + LilvNode* const morph_supportsType; + LilvNode* const rsz_minimumSize; + LilvNode* const work_schedule; Ingen::World& world() { return *_world; } LilvWorld* lv2_world() { return _world->lilv_world(); } diff --git a/src/server/NodeFactory.cpp b/src/server/NodeFactory.cpp index 616a1b35..1544b98b 100644 --- a/src/server/NodeFactory.cpp +++ b/src/server/NodeFactory.cpp @@ -57,9 +57,11 @@ NodeFactory::~NodeFactory() const NodeFactory::Plugins& NodeFactory::plugins() { + ThreadManager::assert_thread(THREAD_PRE_PROCESS); if (!_has_loaded) { // TODO: Plugin list refreshing - load_plugins(); + load_lv2_plugins(); + _has_loaded = true; } return _plugins; } @@ -72,22 +74,6 @@ NodeFactory::plugin(const Raul::URI& uri) return ((i != _plugins.end()) ? i->second : NULL); } -void -NodeFactory::load_plugins() -{ - ThreadManager::assert_thread(THREAD_PRE_PROCESS); - - // Only load if we havn't already, so every client connecting doesn't cause - // this (expensive!) stuff to happen. Not the best solution - would be nice - // if clients could refresh plugins list for whatever reason :/ - if (!_has_loaded) { - _plugins.clear(); - load_internal_plugins(); - load_lv2_plugins(); - _has_loaded = true; - } -} - void NodeFactory::load_internal_plugins() { diff --git a/src/server/NodeFactory.hpp b/src/server/NodeFactory.hpp index a6811c9c..502d7757 100644 --- a/src/server/NodeFactory.hpp +++ b/src/server/NodeFactory.hpp @@ -19,11 +19,11 @@ #include +#include "ingen/World.hpp" +#include "raul/Noncopyable.hpp" #include "raul/SharedPtr.hpp" #include "raul/URI.hpp" -#include "ingen/World.hpp" - namespace Ingen { namespace Server { @@ -36,14 +36,13 @@ class LV2Info; * * \ingroup engine */ -class NodeFactory +class NodeFactory : public Raul::Noncopyable { public: explicit NodeFactory(Ingen::World* world); ~NodeFactory(); void load_plugin(const Raul::URI& uri); - void load_plugins(); typedef std::map Plugins; const Plugins& plugins(); diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 6a57e6a2..61d358c7 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -76,6 +76,12 @@ PortImpl::PortImpl(BufferFactory& bufs, set_property(uris.lv2_index, bufs.forge().make((int32_t)index)); } +PortImpl::~PortImpl() +{ + delete _set_states; + delete _buffers; +} + void PortImpl::set_type(PortType port_type, LV2_URID buffer_type) { @@ -97,11 +103,6 @@ PortImpl::set_type(PortType port_type, LV2_URID buffer_type) _buffer_size = _bufs.default_size(_buffer_type); } -PortImpl::~PortImpl() -{ - delete _buffers; -} - bool PortImpl::supports(const Raul::URI& value_type) const { diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp index da0b2047..4664eb06 100644 --- a/src/server/Worker.cpp +++ b/src/server/Worker.cpp @@ -112,6 +112,11 @@ Worker::Worker(uint32_t buffer_size) start(); } +Worker::~Worker() +{ + free(_buffer); +} + void Worker::_run() { diff --git a/src/server/Worker.hpp b/src/server/Worker.hpp index f23597e6..25300502 100644 --- a/src/server/Worker.hpp +++ b/src/server/Worker.hpp @@ -32,6 +32,7 @@ class Worker : public Raul::Thread { public: Worker(uint32_t buffer_size); + ~Worker(); struct Schedule : public LV2Features::Feature { SharedPtr feature(World* world, GraphObject* n); @@ -49,8 +50,8 @@ private: Raul::Semaphore _sem; Raul::RingBuffer _requests; Raul::RingBuffer _responses; - uint8_t* _buffer; - uint32_t _buffer_size; + uint8_t* const _buffer; + const uint32_t _buffer_size; virtual void _run(); }; -- cgit v1.2.1