diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp
index f3b864081..96fd9dfaa 100644
--- a/source/backend/CarlaEngine.hpp
+++ b/source/backend/CarlaEngine.hpp
@@ -1089,6 +1089,7 @@ protected:
/*!
* Virtual functions for handling patchbay state.
+ * Do not free returned data.
*/
virtual const char* const* getPatchbayConnections() const;
virtual void restorePatchbayConnection(const char* const sourcePort, const char* const targetPort);
diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp
index 49335c0f1..0bd2fb626 100644
--- a/source/backend/engine/CarlaEngine.cpp
+++ b/source/backend/engine/CarlaEngine.cpp
@@ -1140,9 +1140,6 @@ bool CarlaEngine::saveProject(const char* const filename)
out << " \n";
out << " " << connTarget << "\n";
out << " \n";
-
- delete[] connSource;
- delete[] connTarget;
}
out << " \n";
diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp
index 721eae5e8..851d1e0ab 100644
--- a/source/backend/engine/CarlaEngineJack.cpp
+++ b/source/backend/engine/CarlaEngineJack.cpp
@@ -23,6 +23,7 @@
#include "CarlaMathUtils.hpp"
#include "CarlaMIDI.h"
#include "CarlaPatchbayUtils.hpp"
+#include "CarlaStringList.hpp"
#include "jackbridge/JackBridge.hpp"
#include "jackey.h"
@@ -1136,7 +1137,7 @@ public:
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, nullptr);
carla_debug("CarlaEngineJack::getPatchbayConnections()");
- LinkedList connList;
+ CarlaStringList connList;
if (const char** const ports = jackbridge_get_ports(fClient, nullptr, nullptr, JackPortIsOutput))
{
@@ -1151,8 +1152,8 @@ public:
{
for (int j=0; connections[j] != nullptr; ++j)
{
- connList.append(carla_strdup(fullPortName));
- connList.append(carla_strdup(connections[j]));
+ connList.append(fullPortName);
+ connList.append(connections[j]);
}
jackbridge_free(connections);
@@ -1162,20 +1163,12 @@ public:
jackbridge_free(ports);
}
- const size_t connCount(connList.count());
-
- if (connCount == 0)
+ if (connList.count() == 0)
return nullptr;
- const char** const retConns = new const char*[connCount+1];
-
- for (size_t i=0; i < connCount; ++i)
- retConns[i] = connList.getAt(i, nullptr);
+ fRetConns = connList.toCharStringListPtr();
- retConns[connCount] = nullptr;
- connList.clear();
-
- return retConns;
+ return fRetConns;
}
void restorePatchbayConnection(const char* const connSource, const char* const connTarget) override
@@ -1671,6 +1664,8 @@ private:
PatchbayConnectionList fUsedConnections;
LinkedList fNewGroups;
+ mutable CharStringListPtr fRetConns;
+
bool findPluginIdAndIcon(const char* const clientName, int& pluginId, PatchbayIcon& icon) noexcept
{
carla_debug("CarlaEngineJack::findPluginIdAndIcon(\"%s\", ...)", clientName);