diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index a413f2842..f3b864081 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -241,6 +241,7 @@ struct EngineOptions { #ifndef DOXYGEN EngineOptions() noexcept; ~EngineOptions() noexcept; + CARLA_DECLARE_NON_COPY_STRUCT(EngineOptions) #endif }; diff --git a/source/backend/CarlaHost.h b/source/backend/CarlaHost.h index c48de4b8d..898f5e492 100644 --- a/source/backend/CarlaHost.h +++ b/source/backend/CarlaHost.h @@ -137,6 +137,7 @@ typedef struct _CarlaPluginInfo { */ _CarlaPluginInfo() noexcept; ~_CarlaPluginInfo() noexcept; + CARLA_DECLARE_NON_COPY_STRUCT(_CarlaPluginInfo) #endif } CarlaPluginInfo; @@ -212,6 +213,7 @@ typedef struct _CarlaNativePluginInfo { * C++ constructor. */ _CarlaNativePluginInfo() noexcept; + CARLA_DECLARE_NON_COPY_STRUCT(_CarlaNativePluginInfo) #endif } CarlaNativePluginInfo; @@ -267,6 +269,7 @@ typedef struct _CarlaParameterInfo { */ _CarlaParameterInfo() noexcept; ~_CarlaParameterInfo() noexcept; + CARLA_DECLARE_NON_COPY_STRUCT(_CarlaParameterInfo) #endif } CarlaParameterInfo; @@ -292,6 +295,7 @@ typedef struct _CarlaScalePointInfo { */ _CarlaScalePointInfo() noexcept; ~_CarlaScalePointInfo() noexcept; + CARLA_DECLARE_NON_COPY_STRUCT(_CarlaScalePointInfo) #endif } CarlaScalePointInfo; diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index a5a6687c7..3976e337e 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -57,8 +57,10 @@ struct CarlaBackendStandalone { : engine(nullptr), engineCallback(nullptr), engineCallbackPtr(nullptr), + engineOptions(), fileCallback(nullptr), - fileCallbackPtr(nullptr) + fileCallbackPtr(nullptr), + lastError() { #ifdef BUILD_BRIDGE engineOptions.processMode = CB::ENGINE_PROCESS_MODE_BRIDGE; @@ -102,6 +104,8 @@ class CarlaNSM public: CarlaNSM() noexcept : fOscServer(nullptr), + fClientId(), + fProjectPath(), fHasBroadcast(false), fHasShowHideUI(false) {} diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index f3730e877..49335c0f1 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -376,7 +376,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons # ifndef CARLA_OS_WIN if (btype == BINARY_NATIVE) { - bridgeBinary += OS_SEP_STR "carla-bridge-native"; + bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-native"; } else # endif @@ -384,16 +384,16 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons switch (btype) { case BINARY_POSIX32: - bridgeBinary += OS_SEP_STR "carla-bridge-posix32"; + bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-posix32"; break; case BINARY_POSIX64: - bridgeBinary += OS_SEP_STR "carla-bridge-posix64"; + bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-posix64"; break; case BINARY_WIN32: - bridgeBinary += OS_SEP_STR "carla-bridge-win32.exe"; + bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-win32.exe"; break; case BINARY_WIN64: - bridgeBinary += OS_SEP_STR "carla-bridge-win64.exe"; + bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-win64.exe"; break; default: bridgeBinary.clear(); diff --git a/source/backend/engine/CarlaEngineData.cpp b/source/backend/engine/CarlaEngineData.cpp index 4a0683f6c..c8c8a16f7 100644 --- a/source/backend/engine/CarlaEngineData.cpp +++ b/source/backend/engine/CarlaEngineData.cpp @@ -245,7 +245,8 @@ EngineTimeInfo::EngineTimeInfo() noexcept : playing(false), frame(0), usecs(0), - valid(0x0) {} + valid(0x0), + bbt() {} void EngineTimeInfo::clear() noexcept { diff --git a/source/backend/engine/CarlaEngineGraph.cpp b/source/backend/engine/CarlaEngineGraph.cpp index bfa99f31b..710e649de 100644 --- a/source/backend/engine/CarlaEngineGraph.cpp +++ b/source/backend/engine/CarlaEngineGraph.cpp @@ -85,9 +85,26 @@ const char* getCarlaRackFullPortNameFromId(const /*RackGraphCarlaPortIds*/ uint return nullptr; } +// ----------------------------------------------------------------------- +// RackGraph Audio + +RackGraph::Audio::Audio() noexcept + : mutex(), + connectedIn1(), + connectedIn2(), + connectedOut1(), + connectedOut2(), + inBuf{0, 0}, + inBufTmp{0, 0}, + outBuf{0, 0} {} + // ----------------------------------------------------------------------- // RackGraph MIDI +RackGraph::MIDI::MIDI() noexcept + : ins(), + outs() {} + const char* RackGraph::MIDI::getName(const bool isInput, const uint portId) const noexcept { for (LinkedList::Itenerator it = isInput ? ins.begin() : outs.begin(); it.valid(); it.next()) @@ -124,9 +141,13 @@ uint RackGraph::MIDI::getPortId(const bool isInput, const char portName[], bool* // RackGraph RackGraph::RackGraph(const uint32_t bufferSize, const uint32_t ins, const uint32_t outs) noexcept - : inputs(ins), + : connections(), + inputs(ins), outputs(outs), - isOffline(false) + isOffline(false), + retCon(), + audio(), + midi() { audio.inBuf[0] = audio.inBuf[1] = nullptr; audio.inBufTmp[0] = audio.inBufTmp[1] = nullptr; diff --git a/source/backend/engine/CarlaEngineGraph.hpp b/source/backend/engine/CarlaEngineGraph.hpp index 8f16cf891..1b0422541 100644 --- a/source/backend/engine/CarlaEngineGraph.hpp +++ b/source/backend/engine/CarlaEngineGraph.hpp @@ -76,6 +76,10 @@ struct RackGraph { float* inBuf[2]; float* inBufTmp[2]; float* outBuf[2]; + // c++ compat stuff + Audio() noexcept; + CARLA_PREVENT_HEAP_ALLOCATION + CARLA_DECLARE_NON_COPY_CLASS(Audio) } audio; struct MIDI { @@ -83,6 +87,10 @@ struct RackGraph { LinkedList outs; const char* getName(const bool isInput, const uint portId) const noexcept; uint getPortId(const bool isInput, const char portName[], bool* const ok = nullptr) const noexcept; + // c++ compat stuff + MIDI() noexcept; + CARLA_PREVENT_HEAP_ALLOCATION + CARLA_DECLARE_NON_COPY_CLASS(MIDI) } midi; RackGraph(const uint32_t bufferSize, const uint32_t inputs, const uint32_t outputs) noexcept; diff --git a/source/backend/engine/CarlaEngineInternal.cpp b/source/backend/engine/CarlaEngineInternal.cpp index cf1e59a66..38a42fabf 100644 --- a/source/backend/engine/CarlaEngineInternal.cpp +++ b/source/backend/engine/CarlaEngineInternal.cpp @@ -67,7 +67,8 @@ EngineInternalTime::EngineInternalTime() noexcept EngineNextAction::EngineNextAction() noexcept : opcode(kEnginePostActionNull), pluginId(0), - value(0) {} + value(0), + waitEvent() {} EngineNextAction::~EngineNextAction() noexcept { @@ -105,15 +106,25 @@ CarlaEngine::ProtectedData::ProtectedData(CarlaEngine* const engine) noexcept isIdling(0), curPluginCount(0), maxPluginNumber(0), -#ifndef BUILD_BRIDGE nextPluginId(0), - plugins(nullptr) {} -#else - nextPluginId(0) + lastError(), + name(), + options(), + timeInfo(), +#ifndef BUILD_BRIDGE + plugins(nullptr), +#endif + events(), +#ifndef BUILD_BRIDGE + graph(), +#endif + time(), + nextAction() { +#ifdef BUILD_BRIDGE carla_zeroStruct(plugins, 1); -} #endif +} CarlaEngine::ProtectedData::~ProtectedData() noexcept { diff --git a/source/backend/engine/CarlaEngineInternal.hpp b/source/backend/engine/CarlaEngineInternal.hpp index 6f603b8e6..d618609cb 100644 --- a/source/backend/engine/CarlaEngineInternal.hpp +++ b/source/backend/engine/CarlaEngineInternal.hpp @@ -26,6 +26,9 @@ using juce::Atomic; using juce::WaitableEvent; +// FIXME only use CARLA_PREVENT_HEAP_ALLOCATION for structs +// maybe separate macro + CARLA_BACKEND_START_NAMESPACE // ----------------------------------------------------------------------- @@ -87,6 +90,7 @@ private: PatchbayGraph* fPatchbay; }; + CARLA_PREVENT_HEAP_ALLOCATION CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalGraph) }; #endif diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index 65ece04fb..721eae5e8 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -73,7 +73,8 @@ public: : CarlaEngineAudioPort(client, isInputPort), fJackClient(jackClient), fJackPort(jackPort), - kDeletionCallback(delCallback) + kDeletionCallback(delCallback), + leakDetector_CarlaEngineJackAudioPort() { carla_debug("CarlaEngineJackAudioPort::CarlaEngineJackAudioPort(%s, %p, %p)", bool2str(isInputPort), jackClient, jackPort); @@ -163,7 +164,8 @@ public: : CarlaEngineCVPort(client, isInputPort), fJackClient(jackClient), fJackPort(jackPort), - kDeletionCallback(delCallback) + kDeletionCallback(delCallback), + leakDetector_CarlaEngineJackCVPort() { carla_debug("CarlaEngineJackCVPort::CarlaEngineJackCVPort(%s, %p, %p)", bool2str(isInputPort), jackClient, jackPort); @@ -252,7 +254,9 @@ public: fJackClient(jackClient), fJackPort(jackPort), fJackBuffer(nullptr), - kDeletionCallback(delCallback) + fRetEvent(kFallbackJackEngineEvent), + kDeletionCallback(delCallback), + leakDetector_CarlaEngineJackEventPort() { carla_debug("CarlaEngineJackEventPort::CarlaEngineJackEventPort(%s, %p, %p)", bool2str(isInputPort), jackClient, jackPort); @@ -429,7 +433,11 @@ public: CarlaEngineJackClient(const CarlaEngine& engine, jack_client_t* const jackClient) : CarlaEngineClient(engine), fJackClient(jackClient), - fUseClient(engine.getProccessMode() == ENGINE_PROCESS_MODE_SINGLE_CLIENT || engine.getProccessMode() == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS) + fUseClient(engine.getProccessMode() == ENGINE_PROCESS_MODE_SINGLE_CLIENT || engine.getProccessMode() == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS), + fAudioPorts(), + fCVPorts(), + fEventPorts(), + leakDetector_CarlaEngineJackClient() { carla_debug("CarlaEngineJackClient::CarlaEngineJackClient(%p)", jackClient); @@ -619,11 +627,18 @@ public: CarlaEngineJack() : CarlaEngine(), fClient(nullptr), + fTransportPos(), fTransportState(JackTransportStopped), - fFreewheel(false) + fFreewheel(false), #ifdef BUILD_BRIDGE - , fIsRunning(false) + fIsRunning(false), +#else + fUsedGroups(), + fUsedPorts(), + fUsedConnections(), + fNewGroups(), #endif + leakDetector_CarlaEngineJack() { carla_debug("CarlaEngineJack::CarlaEngineJack()"); diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 41789608d..b8062bfe3 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -54,7 +54,8 @@ class CarlaEngineNativeUI : public CarlaExternalUI { public: CarlaEngineNativeUI(CarlaEngine* const engine) - : fEngine(engine) + : fEngine(engine), + leakDetector_CarlaEngineNativeUI() { carla_debug("CarlaEngineNativeUI::CarlaEngineNativeUI(%p)", engine); } @@ -555,7 +556,8 @@ public: fIsPatchbay(isPatchbay), fIsActive(false), fIsRunning(false), - fUiServer(this) + fUiServer(this), + leakDetector_CarlaEngineNative() { carla_debug("CarlaEngineNative::CarlaEngineNative()"); diff --git a/source/backend/engine/CarlaEngineOsc.cpp b/source/backend/engine/CarlaEngineOsc.cpp index 3ca8a39d9..0862a2398 100644 --- a/source/backend/engine/CarlaEngineOsc.cpp +++ b/source/backend/engine/CarlaEngineOsc.cpp @@ -41,8 +41,15 @@ extern int CarlaPluginSetOscBridgeInfo(CarlaPlugin* const plugin, const PluginBr CarlaEngineOsc::CarlaEngineOsc(CarlaEngine* const engine) noexcept : fEngine(engine), +#ifndef BUILD_BRIDGE + fControlData(), +#endif + fName(), + fServerPathTCP(), + fServerPathUDP(), fServerTCP(nullptr), - fServerUDP(nullptr) + fServerUDP(nullptr), + leakDetector_CarlaEngineOsc() { CARLA_SAFE_ASSERT(engine != nullptr); carla_debug("CarlaEngineOsc::CarlaEngineOsc(%p)", engine); diff --git a/source/backend/engine/CarlaEngineOsc.hpp b/source/backend/engine/CarlaEngineOsc.hpp index 15869fd18..14d8e2c5b 100644 --- a/source/backend/engine/CarlaEngineOsc.hpp +++ b/source/backend/engine/CarlaEngineOsc.hpp @@ -93,6 +93,10 @@ public: private: CarlaEngine* const fEngine; +#ifndef BUILD_BRIDGE + CarlaOscData fControlData; // for carla-control +#endif + CarlaString fName; CarlaString fServerPathTCP; @@ -100,10 +104,6 @@ private: lo_server fServerTCP; lo_server fServerUDP; -#ifndef BUILD_BRIDGE - CarlaOscData fControlData; // for carla-control -#endif - // ------------------------------------------------------------------- int handleMessage(const bool isTCP, const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg); diff --git a/source/backend/engine/CarlaEngineRtAudio.cpp b/source/backend/engine/CarlaEngineRtAudio.cpp index 3d81881f5..240781516 100644 --- a/source/backend/engine/CarlaEngineRtAudio.cpp +++ b/source/backend/engine/CarlaEngineRtAudio.cpp @@ -157,7 +157,13 @@ public: fAudioInCount(0), fAudioOutCount(0), fLastEventTime(0), - fMidiOutVector(3) + fDeviceName(), + fMidiIns(), + fMidiInEvents(), + fMidiOuts(), + fMidiOutMutex(), + fMidiOutVector(3), + leakDetector_CarlaEngineRtAudio() { carla_debug("CarlaEngineRtAudio::CarlaEngineRtAudio(%i)", api); @@ -949,7 +955,8 @@ private: RtLinkedList dataPending; RtMidiEvents() - : dataPool(512, 512), + : mutex(), + dataPool(512, 512), data(dataPool), dataPending(dataPool) {} diff --git a/source/backend/engine/CarlaEngineThread.cpp b/source/backend/engine/CarlaEngineThread.cpp index d27b5a58f..0f6d32b49 100644 --- a/source/backend/engine/CarlaEngineThread.cpp +++ b/source/backend/engine/CarlaEngineThread.cpp @@ -25,7 +25,8 @@ CARLA_BACKEND_START_NAMESPACE CarlaEngineThread::CarlaEngineThread(CarlaEngine* const engine) noexcept : CarlaThread("CarlaEngineThread"), - kEngine(engine) + kEngine(engine), + leakDetector_CarlaEngineThread() { CARLA_SAFE_ASSERT(engine != nullptr); carla_debug("CarlaEngineThread::CarlaEngineThread(%p)", engine); diff --git a/source/includes/CarlaDefines.h b/source/includes/CarlaDefines.h index de8f8635f..d1cfcab26 100644 --- a/source/includes/CarlaDefines.h +++ b/source/includes/CarlaDefines.h @@ -200,40 +200,51 @@ private: \ #ifdef CARLA_PROPER_CPP11_SUPPORT # define CARLA_PREVENT_HEAP_ALLOCATION \ private: \ - static void* operator new(size_t) = delete; \ + static void* operator new(std::size_t) = delete; \ static void operator delete(void*) = delete; #else # define CARLA_PREVENT_HEAP_ALLOCATION \ private: \ - static void* operator new(size_t); \ + static void* operator new(std::size_t); \ static void operator delete(void*); #endif -/* Define EXTERN_C */ +/* Define CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION */ +#ifdef CARLA_PROPER_CPP11_SUPPORT +# define CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION \ +private: \ + static void* operator new(std::size_t) = delete; +#else +# define CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION \ +private: \ + static void* operator new(std::size_t); +#endif + +/* Define CARLA_EXTERN_C */ #ifdef __cplusplus -# define EXTERN_C extern "C" +# define CARLA_EXTERN_C extern "C" #else -# define EXTERN_C +# define CARLA_EXTERN_C #endif /* Define CARLA_EXPORT */ #ifdef BUILD_BRIDGE -# define CARLA_EXPORT EXTERN_C +# define CARLA_EXPORT CARLA_EXTERN_C #else # if defined(CARLA_OS_WIN) && ! defined(__WINE__) -# define CARLA_EXPORT EXTERN_C __declspec (dllexport) +# define CARLA_EXPORT CARLA_EXTERN_C __declspec (dllexport) # else -# define CARLA_EXPORT EXTERN_C __attribute__ ((visibility("default"))) +# define CARLA_EXPORT CARLA_EXTERN_C __attribute__ ((visibility("default"))) # endif #endif /* Define OS_SEP */ #ifdef CARLA_OS_WIN -# define OS_SEP '\\' -# define OS_SEP_STR "\\" +# define CARLA_OS_SEP '\\' +# define CARLA_OS_SEP_STR "\\" #else -# define OS_SEP '/' -# define OS_SEP_STR "/" +# define CARLA_OS_SEP '/' +# define CARLA_OS_SEP_STR "/" #endif /* Useful typedefs */ diff --git a/source/tests/CarlaUtils1.cpp b/source/tests/CarlaUtils1.cpp index 87281473f..3d65c6235 100644 --- a/source/tests/CarlaUtils1.cpp +++ b/source/tests/CarlaUtils1.cpp @@ -121,6 +121,8 @@ static void test_CarlaUtils() str4 = nullptr; } } + + CARLA_DECLARE_NON_COPY_STRUCT(TestStruct) }; TestStruct a, b, c; diff --git a/source/tests/CarlaUtils3.cpp b/source/tests/CarlaUtils3.cpp index 5551b2bf7..52ab95357 100644 --- a/source/tests/CarlaUtils3.cpp +++ b/source/tests/CarlaUtils3.cpp @@ -30,8 +30,9 @@ class LeakTestClass { public: - LeakTestClass()noexcept - : i(0) {} + LeakTestClass() noexcept + : i(0), + leakDetector_LeakTestClass() {} private: int i; diff --git a/source/utils/CarlaBinaryUtils.hpp b/source/utils/CarlaBinaryUtils.hpp index bcad303f3..6a073b220 100644 --- a/source/utils/CarlaBinaryUtils.hpp +++ b/source/utils/CarlaBinaryUtils.hpp @@ -56,6 +56,9 @@ public: private: const magic_t fMagic; + + CARLA_PREVENT_HEAP_ALLOCATION + CARLA_DECLARE_NON_COPY_STRUCT(CarlaMagic) }; static const CarlaMagic& getCarlaMagicInstance() diff --git a/source/utils/CarlaExternalUI.hpp b/source/utils/CarlaExternalUI.hpp index c7e3a12cb..4610dac13 100644 --- a/source/utils/CarlaExternalUI.hpp +++ b/source/utils/CarlaExternalUI.hpp @@ -33,9 +33,11 @@ public: }; CarlaExternalUI() - : fUiState(UiNone) - { - } + : fFilename(), + fSampleRate(), + fUiTitle(), + fUiState(UiNone), + leakDetector_CarlaExternalUI() {} ~CarlaExternalUI() override { diff --git a/source/utils/CarlaJuceUtils.hpp b/source/utils/CarlaJuceUtils.hpp index d5f9fff7a..3264c10ea 100644 --- a/source/utils/CarlaJuceUtils.hpp +++ b/source/utils/CarlaJuceUtils.hpp @@ -45,7 +45,7 @@ #define CARLA_LEAK_DETECTOR(ClassName) \ friend class ::LeakedObjectDetector; \ static const char* getLeakedObjectClassName() noexcept { return #ClassName; } \ - ::LeakedObjectDetector CARLA_JOIN_MACRO(leakDetector, __LINE__); + ::LeakedObjectDetector CARLA_JOIN_MACRO(leakDetector_, ClassName); #define CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ClassName) \ CARLA_DECLARE_NON_COPY_CLASS(ClassName) \ @@ -96,9 +96,7 @@ private: { public: LeakCounter() noexcept - { - numObjects = 0; - } + : numObjects(0) {} ~LeakCounter() noexcept { diff --git a/source/utils/CarlaLibCounter.hpp b/source/utils/CarlaLibCounter.hpp index 49c27fa70..574d30330 100644 --- a/source/utils/CarlaLibCounter.hpp +++ b/source/utils/CarlaLibCounter.hpp @@ -27,7 +27,9 @@ class LibCounter { public: - LibCounter() noexcept {} + LibCounter() noexcept + : fMutex(), + fLibs() {} ~LibCounter() noexcept { diff --git a/source/utils/CarlaLv2Utils.hpp b/source/utils/CarlaLv2Utils.hpp index 0bcaa8648..6162a7fa6 100644 --- a/source/utils/CarlaLv2Utils.hpp +++ b/source/utils/CarlaLv2Utils.hpp @@ -429,7 +429,7 @@ public: return cState; } - CARLA_PREVENT_HEAP_ALLOCATION + CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION }; // ----------------------------------------------------------------------- diff --git a/source/utils/CarlaMutex.hpp b/source/utils/CarlaMutex.hpp index fffaace87..02e5d9960 100644 --- a/source/utils/CarlaMutex.hpp +++ b/source/utils/CarlaMutex.hpp @@ -32,7 +32,8 @@ public: * Constructor. */ CarlaMutex() noexcept - : fTryLockWasCalled(false) + : fMutex(), + fTryLockWasCalled(false) { pthread_mutex_init(&fMutex, nullptr); } @@ -103,6 +104,11 @@ public: * Constructor. */ CarlaRecursiveMutex() noexcept +#ifdef CARLA_OS_WIN + : fSection() +#else + : fMutex() +#endif { #ifdef CARLA_OS_WIN InitializeCriticalSection(&fSection); diff --git a/source/utils/CarlaPatchbayUtils.hpp b/source/utils/CarlaPatchbayUtils.hpp index e81298912..094cbf97d 100644 --- a/source/utils/CarlaPatchbayUtils.hpp +++ b/source/utils/CarlaPatchbayUtils.hpp @@ -66,7 +66,8 @@ struct PatchbayGroupList { LinkedList list; PatchbayGroupList() noexcept - : lastId(0) {} + : lastId(0), + list() {} void clear() noexcept { @@ -159,7 +160,8 @@ struct PatchbayPortList { LinkedList list; PatchbayPortList() noexcept - : lastId(0) {} + : lastId(0), + list() {} void clear() noexcept { @@ -247,7 +249,8 @@ struct PatchbayConnectionList { LinkedList list; PatchbayConnectionList() noexcept - : lastId(0) {} + : lastId(0), + list() {} void clear() noexcept { diff --git a/source/utils/CarlaPipeUtils.hpp b/source/utils/CarlaPipeUtils.hpp index 1d1bde0ef..406efc0b6 100644 --- a/source/utils/CarlaPipeUtils.hpp +++ b/source/utils/CarlaPipeUtils.hpp @@ -39,10 +39,12 @@ class CarlaPipeServer { protected: CarlaPipeServer() - : fPipeRecv(-1), + : fWriteLock(), + fPipeRecv(-1), fPipeSend(-1), fIsReading(false), - fPid(-1) + fPid(-1), + fTmpStr() { carla_debug("CarlaPipeServer::CarlaPipeServer()"); diff --git a/source/utils/CarlaPluginUI.cpp b/source/utils/CarlaPluginUI.cpp index 9f3e7a627..fdffd3f7d 100644 --- a/source/utils/CarlaPluginUI.cpp +++ b/source/utils/CarlaPluginUI.cpp @@ -41,10 +41,10 @@ static int temporaryErrorHandler(Display*, XErrorEvent*) return 0; } -class X11PluginUi : public CarlaPluginUI +class X11PluginUI : public CarlaPluginUI { public: - X11PluginUi(CloseCallback* const cb, const uintptr_t parentId) noexcept + X11PluginUI(CloseCallback* const cb, const uintptr_t parentId) noexcept : CarlaPluginUI(cb), fDisplay(nullptr), fWindow(0), @@ -88,7 +88,7 @@ public: setTransientWinId(parentId); } - ~X11PluginUi() override + ~X11PluginUI() override { CARLA_SAFE_ASSERT(! fIsVisible); @@ -293,6 +293,8 @@ private: bool fIsVisible; bool fFirstShow; EventProcPtr fEventProc; + + CARLA_DECLARE_NON_COPY_CLASS(X11PluginUI) }; #endif @@ -314,6 +316,9 @@ bool CarlaPluginUI::tryTransientWinIdMatch(const uintptr_t pid, const char* cons Display* display; ScopedDisplay() : display(XOpenDisplay(nullptr)) {} ~ScopedDisplay() { if (display!=nullptr) XCloseDisplay(display); } + // c++ compat stuff + CARLA_PREVENT_HEAP_ALLOCATION + CARLA_DECLARE_NON_COPY_CLASS(ScopedDisplay) }; struct ScopedFreeData { union { @@ -323,6 +328,9 @@ bool CarlaPluginUI::tryTransientWinIdMatch(const uintptr_t pid, const char* cons ScopedFreeData(char* d) : data(d) {} ScopedFreeData(uchar* d) : udata(d) {} ~ScopedFreeData() { XFree(data); } + // c++ compat stuff + CARLA_PREVENT_HEAP_ALLOCATION + CARLA_DECLARE_NON_COPY_CLASS(ScopedFreeData) }; const ScopedDisplay sd; @@ -502,7 +510,7 @@ CarlaPluginUI* CarlaPluginUI::newWindows(CloseCallback*, uintptr_t) #ifdef HAVE_X11 CarlaPluginUI* CarlaPluginUI::newX11(CloseCallback* cb, uintptr_t parentId) { - return new X11PluginUi(cb, parentId); + return new X11PluginUI(cb, parentId); } #endif diff --git a/source/utils/CarlaPluginUI.hpp b/source/utils/CarlaPluginUI.hpp index 6ca7d1287..3676de2c7 100644 --- a/source/utils/CarlaPluginUI.hpp +++ b/source/utils/CarlaPluginUI.hpp @@ -60,6 +60,8 @@ protected: bool fIsIdling; CloseCallback* fCallback; CarlaPluginUI(CloseCallback* const cb) noexcept : fIsIdling(false), fCallback(cb) {} + + CARLA_DECLARE_NON_COPY_CLASS(CarlaPluginUI) }; // ----------------------------------------------------- diff --git a/source/utils/CarlaRingBuffer.hpp b/source/utils/CarlaRingBuffer.hpp index 761103129..6bd0a984d 100644 --- a/source/utils/CarlaRingBuffer.hpp +++ b/source/utils/CarlaRingBuffer.hpp @@ -75,6 +75,9 @@ struct BigStackBuffer { uint8_t buf[size]; }; +#define HeapBuffer_INIT {0, 0, 0, 0, false, nullptr} +#define StackBuffer_INIT {0, 0, 0, false, {0}} + // ----------------------------------------------------------------------- // CarlaRingBuffer templated class @@ -85,12 +88,9 @@ public: CarlaRingBuffer() noexcept : fBuffer(nullptr) {} - CarlaRingBuffer(BufferStruct* const ringBuf) noexcept - : fBuffer(ringBuf) - { - if (ringBuf != nullptr) - clear(); - } + virtual ~CarlaRingBuffer() noexcept {} + + // ------------------------------------------------------------------- void clear() noexcept { @@ -376,7 +376,7 @@ protected: private: BufferStruct* fBuffer; - CARLA_PREVENT_HEAP_ALLOCATION + CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION CARLA_DECLARE_NON_COPY_CLASS(CarlaRingBuffer) }; @@ -387,12 +387,9 @@ class CarlaHeapRingBuffer : public CarlaRingBuffer { public: CarlaHeapRingBuffer() noexcept - : CarlaRingBuffer() - { - carla_zeroStruct(fHeapBuffer); - } + : fHeapBuffer(HeapBuffer_INIT) {} - ~CarlaHeapRingBuffer() noexcept + ~CarlaHeapRingBuffer() noexcept override { if (fHeapBuffer.buf == nullptr) return; @@ -430,7 +427,7 @@ public: private: HeapBuffer fHeapBuffer; - CARLA_PREVENT_HEAP_ALLOCATION + CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION CARLA_DECLARE_NON_COPY_CLASS(CarlaHeapRingBuffer) }; @@ -441,12 +438,15 @@ class CarlaStackRingBuffer : public CarlaRingBuffer { public: CarlaStackRingBuffer() noexcept - : CarlaRingBuffer(&fStackBuffer) {} + : fStackBuffer(StackBuffer_INIT) + { + setRingBuffer(&fStackBuffer, false); + } private: StackBuffer fStackBuffer; - CARLA_PREVENT_HEAP_ALLOCATION + CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION CARLA_DECLARE_NON_COPY_CLASS(CarlaStackRingBuffer) }; diff --git a/source/utils/CarlaStateUtils.cpp b/source/utils/CarlaStateUtils.cpp index bcac3e437..0eed9ddb9 100644 --- a/source/utils/CarlaStateUtils.cpp +++ b/source/utils/CarlaStateUtils.cpp @@ -152,7 +152,9 @@ StateSave::StateSave() noexcept currentProgramName(nullptr), currentMidiBank(-1), currentMidiProgram(-1), - chunk(nullptr) {} + chunk(nullptr), + parameters(), + customData() {} StateSave::~StateSave() noexcept { diff --git a/source/utils/CarlaString.hpp b/source/utils/CarlaString.hpp index 023f471e6..e562041a9 100644 --- a/source/utils/CarlaString.hpp +++ b/source/utils/CarlaString.hpp @@ -40,20 +40,20 @@ public: * Empty string. */ explicit CarlaString() noexcept - { - _init(); - } + : fBuffer(_null()), + fBufferLen(0) {} /* * Simple character. */ explicit CarlaString(const char c) noexcept + : fBuffer(_null()), + fBufferLen(0) { char ch[2]; ch[0] = c; ch[1] = '\0'; - _init(); _dup(ch); } @@ -61,8 +61,9 @@ public: * Simple char string. */ explicit CarlaString(char* const strBuf) noexcept + : fBuffer(_null()), + fBufferLen(0) { - _init(); _dup(strBuf); } @@ -70,8 +71,9 @@ public: * Simple const char string. */ explicit CarlaString(const char* const strBuf) noexcept + : fBuffer(_null()), + fBufferLen(0) { - _init(); _dup(strBuf); } @@ -79,12 +81,13 @@ public: * Integer. */ explicit CarlaString(const int value) noexcept + : fBuffer(_null()), + fBufferLen(0) { char strBuf[0xff+1]; std::snprintf(strBuf, 0xff, "%d", value); strBuf[0xff] = '\0'; - _init(); _dup(strBuf); } @@ -92,12 +95,13 @@ public: * Unsigned integer, possibly in hexadecimal. */ explicit CarlaString(const unsigned int value, const bool hexadecimal = false) noexcept + : fBuffer(_null()), + fBufferLen(0) { char strBuf[0xff+1]; std::snprintf(strBuf, 0xff, hexadecimal ? "0x%x" : "%u", value); strBuf[0xff] = '\0'; - _init(); _dup(strBuf); } @@ -105,12 +109,13 @@ public: * Long integer. */ explicit CarlaString(const long value) noexcept + : fBuffer(_null()), + fBufferLen(0) { char strBuf[0xff+1]; std::snprintf(strBuf, 0xff, "%ld", value); strBuf[0xff] = '\0'; - _init(); _dup(strBuf); } @@ -118,12 +123,13 @@ public: * Long unsigned integer, possibly hexadecimal. */ explicit CarlaString(const unsigned long value, const bool hexadecimal = false) noexcept + : fBuffer(_null()), + fBufferLen(0) { char strBuf[0xff+1]; std::snprintf(strBuf, 0xff, hexadecimal ? "0x%lx" : "%lu", value); strBuf[0xff] = '\0'; - _init(); _dup(strBuf); } @@ -131,12 +137,13 @@ public: * Long long integer. */ explicit CarlaString(const long long value) noexcept + : fBuffer(_null()), + fBufferLen(0) { char strBuf[0xff+1]; std::snprintf(strBuf, 0xff, "%lld", value); strBuf[0xff] = '\0'; - _init(); _dup(strBuf); } @@ -144,12 +151,13 @@ public: * Long long unsigned integer, possibly hexadecimal. */ explicit CarlaString(const unsigned long long value, const bool hexadecimal = false) noexcept + : fBuffer(_null()), + fBufferLen(0) { char strBuf[0xff+1]; std::snprintf(strBuf, 0xff, hexadecimal ? "0x%llx" : "%llu", value); strBuf[0xff] = '\0'; - _init(); _dup(strBuf); } @@ -157,12 +165,13 @@ public: * Single-precision floating point number. */ explicit CarlaString(const float value) noexcept + : fBuffer(_null()), + fBufferLen(0) { char strBuf[0xff+1]; std::snprintf(strBuf, 0xff, "%f", value); strBuf[0xff] = '\0'; - _init(); _dup(strBuf); } @@ -170,12 +179,13 @@ public: * Double-precision floating point number. */ explicit CarlaString(const double value) noexcept + : fBuffer(_null()), + fBufferLen(0) { char strBuf[0xff+1]; std::snprintf(strBuf, 0xff, "%g", value); strBuf[0xff] = '\0'; - _init(); _dup(strBuf); } @@ -186,8 +196,9 @@ public: * Create string from another string. */ CarlaString(const CarlaString& str) noexcept + : fBuffer(_null()), + fBufferLen(0) { - _init(); _dup(str.fBuffer); } @@ -750,16 +761,6 @@ private: return &sNull; } - /* - * Shared init function. - * Called on all constructors. - */ - void _init() noexcept - { - fBuffer = _null(); - fBufferLen = 0; - } - /* * Helper function. * Called whenever the string needs to be allocated. @@ -783,7 +784,11 @@ private: fBuffer = (char*)std::malloc(fBufferLen+1); if (fBuffer == nullptr) - return _init(); + { + fBuffer = _null(); + fBufferLen = 0; + return; + } std::strcpy(fBuffer, strBuf); @@ -800,7 +805,8 @@ private: CARLA_SAFE_ASSERT(fBuffer != nullptr); std::free(fBuffer); - _init(); + fBuffer = _null(); + fBufferLen = 0; } } diff --git a/source/utils/CarlaStringList.hpp b/source/utils/CarlaStringList.hpp index b8c653111..b3fe9a507 100644 --- a/source/utils/CarlaStringList.hpp +++ b/source/utils/CarlaStringList.hpp @@ -18,7 +18,6 @@ #ifndef CARLA_STRING_LIST_HPP_INCLUDED #define CARLA_STRING_LIST_HPP_INCLUDED -#include "CarlaString.hpp" #include "LinkedList.hpp" // ----------------------------------------------------------------------- @@ -39,7 +38,7 @@ public: copy(ptr.fCharList); } - CharStringListPtr(const LinkedList& list) noexcept + CharStringListPtr(const LinkedList& list) noexcept : fCharList(nullptr) { copy(list); @@ -50,6 +49,8 @@ public: clear(); } + // ------------------------------------------------------------------- + operator const char* const*() const noexcept { return fCharList; @@ -69,13 +70,15 @@ public: return *this; } - CharStringListPtr& operator=(const LinkedList& list) noexcept + CharStringListPtr& operator=(const LinkedList& list) noexcept { clear(); copy(list); return *this; } + // ------------------------------------------------------------------- + protected: void clear() noexcept { @@ -119,7 +122,7 @@ protected: fCharList = tmpList; } - void copy(const LinkedList& list) noexcept + void copy(const LinkedList& list) noexcept { CARLA_SAFE_ASSERT_RETURN(fCharList == nullptr,); @@ -133,23 +136,18 @@ protected: } CARLA_SAFE_EXCEPTION_RETURN("CharStringListPtr::copy",); size_t i=0; - for (LinkedList::Itenerator it = list.begin(); it.valid(); it.next(), ++i) + for (LinkedList::Itenerator it = list.begin(); it.valid(); it.next(), ++i) { - const CarlaString& string(it.getValue()); - - try { - tmpList[i] = string.dup(); - } - catch(...) { - tmpList[i] = nullptr; - break; - } + tmpList[i] = carla_strdup_safe(it.getValue()); + CARLA_SAFE_ASSERT_BREAK(tmpList[i] != nullptr); } tmpList[count] = nullptr; fCharList = tmpList; } + // ------------------------------------------------------------------- + private: const char* const* fCharList; }; @@ -157,50 +155,144 @@ private: // ----------------------------------------------------------------------- // CarlaStringList -class CarlaStringList : public LinkedList +class CarlaStringList : public LinkedList { public: CarlaStringList() noexcept - : LinkedList(true) {} + : LinkedList() {} -#if 0 CarlaStringList(const CarlaStringList& list) noexcept - : LinkedList(true) + : LinkedList() { for (Itenerator it = list.begin(); it.valid(); it.next()) - LinkedList::append(it.getValue()); + LinkedList::append(carla_strdup_safe(it.getValue())); } -#endif - ~CarlaStringList() noexcept + ~CarlaStringList() noexcept override { clear(); } - bool append(const char* const strBuf) noexcept + // ------------------------------------------------------------------- + + void clear() noexcept + { + for (Itenerator it = begin(); it.valid(); it.next()) + { + if (const char* const string = it.getValue()) + delete[] string; + } + + LinkedList::clear(); + } + + // ------------------------------------------------------------------- + + bool append(const char* const string) noexcept + { + CARLA_SAFE_ASSERT_RETURN(string != nullptr, false); + + if (const char* const stringDup = carla_strdup_safe(string)) + { + if (LinkedList::append(stringDup)) + return true; + delete[] stringDup; + } + + return false; + } + + bool appendAt(const char* const string, const Itenerator& it) noexcept + { + CARLA_SAFE_ASSERT_RETURN(string != nullptr, false); + + if (const char* const stringDup = carla_strdup_safe(string)) + { + if (LinkedList::appendAt(stringDup, it)) + return true; + delete[] stringDup; + } + + return false; + } + + bool insert(const char* const string) noexcept + { + CARLA_SAFE_ASSERT_RETURN(string != nullptr, false); + + if (const char* const stringDup = carla_strdup_safe(string)) + { + if (LinkedList::insert(stringDup)) + return true; + delete[] stringDup; + } + + return false; + } + + bool insertAt(const char* const string, const Itenerator& it) noexcept { - const CarlaString string(strBuf); - return LinkedList::append(string); + CARLA_SAFE_ASSERT_RETURN(string != nullptr, false); + + if (const char* const stringDup = carla_strdup_safe(string)) + { + if (LinkedList::insertAt(stringDup, it)) + return true; + delete[] stringDup; + } + + return false; } - bool appendAt(const char* const strBuf, const Itenerator& it) noexcept + // ------------------------------------------------------------------- + + void remove(Itenerator& it) noexcept { - const CarlaString string(strBuf); - return LinkedList::appendAt(string, it); + if (const char* const string = it.getValue()) + delete[] string; + + LinkedList::remove(it); } - bool insert(const char* const strBuf) noexcept + bool removeOne(const char* const string) noexcept { - const CarlaString string(strBuf); - return LinkedList::insert(string); + CARLA_SAFE_ASSERT_RETURN(string != nullptr, false); + + for (Itenerator it = begin(); it.valid(); it.next()) + { + const char* const stringComp(it.getValue()); + CARLA_SAFE_ASSERT_CONTINUE(stringComp != nullptr); + + if (std::strcmp(string, stringComp) != 0) + continue; + + delete[] stringComp; + LinkedList::remove(it); + return true; + } + + return false; } - bool insertAt(const char* const strBuf, const Itenerator& it) noexcept + void removeAll(const char* const string) noexcept { - const CarlaString string(strBuf); - return LinkedList::insertAt(string, it); + CARLA_SAFE_ASSERT_RETURN(string != nullptr,); + + for (Itenerator it = begin(); it.valid(); it.next()) + { + const char* const stringComp(it.getValue()); + CARLA_SAFE_ASSERT_CONTINUE(stringComp != nullptr); + + if (std::strcmp(string, stringComp) != 0) + continue; + + delete[] stringComp; + LinkedList::remove(it); + } } + // ------------------------------------------------------------------- + CharStringListPtr toCharStringListPtr() const noexcept { return CharStringListPtr(*this); @@ -210,8 +302,13 @@ public: { clear(); + CARLA_SAFE_ASSERT_RETURN(charStringList != nullptr, *this); + for (int i=0; charStringList[i] != nullptr; ++i) - append(charStringList[i]); + { + if (const char* const string = carla_strdup_safe(charStringList[i])) + LinkedList::append(string); + } return *this; } @@ -221,13 +318,15 @@ public: clear(); for (Itenerator it = list.begin(); it.valid(); it.next()) - LinkedList::append(it.getValue()); + { + if (const char* const string = carla_strdup_safe(it.getValue())) + LinkedList::append(string); + } return *this; } -private: - LinkedList fList; + CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION }; // ----------------------------------------------------------------------- diff --git a/source/utils/CarlaThread.hpp b/source/utils/CarlaThread.hpp index e6522b0ca..aba8e3208 100644 --- a/source/utils/CarlaThread.hpp +++ b/source/utils/CarlaThread.hpp @@ -37,11 +37,14 @@ protected: * Constructor. */ CarlaThread(const char* const threadName = nullptr) noexcept - : fName(threadName), - fShouldExit(false) - { - _init(); - } + : fLock(), + fName(threadName), +#ifdef PTW32_DLLPORT + fHandle({nullptr, 0}), +#else + fHandle(0), +#endif + fShouldExit(false) {} /* * Destructor. diff --git a/source/utils/LinkedList.hpp b/source/utils/LinkedList.hpp index 165447163..e152b5755 100644 --- a/source/utils/LinkedList.hpp +++ b/source/utils/LinkedList.hpp @@ -20,8 +20,6 @@ #include "CarlaUtils.hpp" -#include - // ----------------------------------------------------------------------- // Define list_entry and list_entry_const @@ -47,27 +45,11 @@ ((const type *)((const char *)(ptr)-offsetof(type, member))) #endif -// ----------------------------------------------------------------------- -// Declare non copyable and prevent heap allocation - -#ifdef CARLA_PROPER_CPP11_SUPPORT -# define LINKED_LIST_DECLARATIONS(ClassName) \ - ClassName(ClassName&) = delete; \ - ClassName(const ClassName&) = delete; \ - ClassName& operator=(const ClassName&) = delete; \ - static void* operator new(size_t) = delete; -#else -# define LINKED_LIST_DECLARATIONS(ClassName) \ - ClassName(ClassName&); \ - ClassName(const ClassName&); \ - ClassName& operator=(const ClassName&); -#endif - // ----------------------------------------------------------------------- // Abstract Linked List class // _allocate() and _deallocate are virtual calls provided by subclasses -// NOTE: data-type classes are not allowed to throw +// NOTE: this class is meant for non-polymorphic data types only! template class AbstractLinkedList @@ -83,12 +65,10 @@ protected: ListHead siblings; }; - AbstractLinkedList(const bool isClass) noexcept - : kIsClass(isClass), - kDataSize(sizeof(Data)) - { - _init(); - } + AbstractLinkedList() noexcept + : kDataSize(sizeof(Data)), + fCount(0), + fQueue({&fQueue, &fQueue}) {} public: virtual ~AbstractLinkedList() noexcept @@ -158,8 +138,6 @@ public: Data* const data = list_entry(entry, Data, siblings); CARLA_SAFE_ASSERT_CONTINUE(data != nullptr); - if (kIsClass) - data->~Data(); _deallocate(data); } @@ -364,7 +342,6 @@ public: } protected: - const bool kIsClass; const size_t kDataSize; size_t fCount; @@ -383,11 +360,9 @@ private: void _createData(Data* const data, const T& value) noexcept { - if (kIsClass) - new(data)Data(); - - data->value = value; ++fCount; + data->value = value; + //std::memcpy(data->value, value, kDataSize); } bool _add(const T& value, const bool inTail, ListHead* const queue) noexcept @@ -397,9 +372,9 @@ private: _createData(data, value); if (inTail) - __list_add(&data->siblings, queue->prev, queue); + __list_add(data->siblings, queue->prev, queue); else - __list_add(&data->siblings, queue, queue->next); + __list_add(data->siblings, queue, queue->next); return true; } @@ -413,11 +388,8 @@ private: entry->next = nullptr; entry->prev = nullptr; - --fCount; - - if (kIsClass) - data->~Data(); _deallocate(data); + --fCount; } const T& _get(ListHead* const entry, const T& fallback) const noexcept @@ -454,12 +426,12 @@ private: /* * Insert a new entry between two known consecutive entries. */ - static void __list_add(ListHead* const new_, ListHead* const prev, ListHead* const next) noexcept + static void __list_add(ListHead& newl, ListHead* const prev, ListHead* const next) noexcept { - next->prev = new_; - new_->next = next; - new_->prev = prev; - prev->next = new_; + next->prev = &newl; + newl.next = next; + newl.prev = prev; + prev->next = &newl; } /* @@ -479,10 +451,10 @@ private: ListHead* const at = head->next; first->prev = head; - head->next = first; + head->next = first; last->next = at; - at->prev = last; + at->prev = last; } static void __list_splice_tail(ListHead* const list, ListHead* const head) noexcept @@ -492,7 +464,7 @@ private: ListHead* const at = head->prev; first->prev = at; - at->next = first; + at->next = first; last->next = head; head->prev = last; @@ -500,7 +472,8 @@ private: template friend class RtLinkedList; - LINKED_LIST_DECLARATIONS(AbstractLinkedList) + CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION + CARLA_DECLARE_NON_COPY_CLASS(AbstractLinkedList) }; // ----------------------------------------------------------------------- @@ -510,8 +483,7 @@ template class LinkedList : public AbstractLinkedList { public: - LinkedList(const bool isClass = false) noexcept - : AbstractLinkedList(isClass) {} + LinkedList() noexcept {} protected: typename AbstractLinkedList::Data* _allocate() noexcept override @@ -526,7 +498,8 @@ protected: std::free(dataPtr); } - LINKED_LIST_DECLARATIONS(LinkedList) + CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION + CARLA_DECLARE_NON_COPY_CLASS(LinkedList) }; // ----------------------------------------------------------------------- diff --git a/source/utils/RtLinkedList.hpp b/source/utils/RtLinkedList.hpp index 93f808eb9..e956c41fb 100644 --- a/source/utils/RtLinkedList.hpp +++ b/source/utils/RtLinkedList.hpp @@ -93,14 +93,16 @@ public: private: mutable RtMemPool_Handle fHandle; const size_t kDataSize; + + CARLA_PREVENT_HEAP_ALLOCATION + CARLA_DECLARE_NON_COPY_CLASS(Pool) }; // ------------------------------------------------------------------- // Now the actual rt-linkedlist code - RtLinkedList(Pool& memPool, const bool isClass = false) noexcept - : AbstractLinkedList(isClass), - fMemPool(memPool) {} + RtLinkedList(Pool& memPool) noexcept + : fMemPool(memPool) {} bool append_sleepy(const T& value) noexcept { @@ -161,9 +163,9 @@ private: this->_createData(data, value); if (inTail) - this->__list_add(&data->siblings, this->fQueue.prev, &this->fQueue); + this->__list_add(data->siblings, this->fQueue.prev, &(this->fQueue)); else - this->__list_add(&data->siblings, &this->fQueue, this->fQueue.next); + this->__list_add(data->siblings, &(this->fQueue), this->fQueue.next); return true; } @@ -171,7 +173,8 @@ private: return false; } - LINKED_LIST_DECLARATIONS(RtLinkedList) + CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION + CARLA_DECLARE_NON_COPY_CLASS(RtLinkedList) }; // -----------------------------------------------------------------------