| @@ -241,6 +241,7 @@ struct EngineOptions { | |||||
| #ifndef DOXYGEN | #ifndef DOXYGEN | ||||
| EngineOptions() noexcept; | EngineOptions() noexcept; | ||||
| ~EngineOptions() noexcept; | ~EngineOptions() noexcept; | ||||
| CARLA_DECLARE_NON_COPY_STRUCT(EngineOptions) | |||||
| #endif | #endif | ||||
| }; | }; | ||||
| @@ -137,6 +137,7 @@ typedef struct _CarlaPluginInfo { | |||||
| */ | */ | ||||
| _CarlaPluginInfo() noexcept; | _CarlaPluginInfo() noexcept; | ||||
| ~_CarlaPluginInfo() noexcept; | ~_CarlaPluginInfo() noexcept; | ||||
| CARLA_DECLARE_NON_COPY_STRUCT(_CarlaPluginInfo) | |||||
| #endif | #endif | ||||
| } CarlaPluginInfo; | } CarlaPluginInfo; | ||||
| @@ -212,6 +213,7 @@ typedef struct _CarlaNativePluginInfo { | |||||
| * C++ constructor. | * C++ constructor. | ||||
| */ | */ | ||||
| _CarlaNativePluginInfo() noexcept; | _CarlaNativePluginInfo() noexcept; | ||||
| CARLA_DECLARE_NON_COPY_STRUCT(_CarlaNativePluginInfo) | |||||
| #endif | #endif | ||||
| } CarlaNativePluginInfo; | } CarlaNativePluginInfo; | ||||
| @@ -267,6 +269,7 @@ typedef struct _CarlaParameterInfo { | |||||
| */ | */ | ||||
| _CarlaParameterInfo() noexcept; | _CarlaParameterInfo() noexcept; | ||||
| ~_CarlaParameterInfo() noexcept; | ~_CarlaParameterInfo() noexcept; | ||||
| CARLA_DECLARE_NON_COPY_STRUCT(_CarlaParameterInfo) | |||||
| #endif | #endif | ||||
| } CarlaParameterInfo; | } CarlaParameterInfo; | ||||
| @@ -292,6 +295,7 @@ typedef struct _CarlaScalePointInfo { | |||||
| */ | */ | ||||
| _CarlaScalePointInfo() noexcept; | _CarlaScalePointInfo() noexcept; | ||||
| ~_CarlaScalePointInfo() noexcept; | ~_CarlaScalePointInfo() noexcept; | ||||
| CARLA_DECLARE_NON_COPY_STRUCT(_CarlaScalePointInfo) | |||||
| #endif | #endif | ||||
| } CarlaScalePointInfo; | } CarlaScalePointInfo; | ||||
| @@ -57,8 +57,10 @@ struct CarlaBackendStandalone { | |||||
| : engine(nullptr), | : engine(nullptr), | ||||
| engineCallback(nullptr), | engineCallback(nullptr), | ||||
| engineCallbackPtr(nullptr), | engineCallbackPtr(nullptr), | ||||
| engineOptions(), | |||||
| fileCallback(nullptr), | fileCallback(nullptr), | ||||
| fileCallbackPtr(nullptr) | |||||
| fileCallbackPtr(nullptr), | |||||
| lastError() | |||||
| { | { | ||||
| #ifdef BUILD_BRIDGE | #ifdef BUILD_BRIDGE | ||||
| engineOptions.processMode = CB::ENGINE_PROCESS_MODE_BRIDGE; | engineOptions.processMode = CB::ENGINE_PROCESS_MODE_BRIDGE; | ||||
| @@ -102,6 +104,8 @@ class CarlaNSM | |||||
| public: | public: | ||||
| CarlaNSM() noexcept | CarlaNSM() noexcept | ||||
| : fOscServer(nullptr), | : fOscServer(nullptr), | ||||
| fClientId(), | |||||
| fProjectPath(), | |||||
| fHasBroadcast(false), | fHasBroadcast(false), | ||||
| fHasShowHideUI(false) {} | fHasShowHideUI(false) {} | ||||
| @@ -376,7 +376,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons | |||||
| # ifndef CARLA_OS_WIN | # ifndef CARLA_OS_WIN | ||||
| if (btype == BINARY_NATIVE) | if (btype == BINARY_NATIVE) | ||||
| { | { | ||||
| bridgeBinary += OS_SEP_STR "carla-bridge-native"; | |||||
| bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-native"; | |||||
| } | } | ||||
| else | else | ||||
| # endif | # endif | ||||
| @@ -384,16 +384,16 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons | |||||
| switch (btype) | switch (btype) | ||||
| { | { | ||||
| case BINARY_POSIX32: | case BINARY_POSIX32: | ||||
| bridgeBinary += OS_SEP_STR "carla-bridge-posix32"; | |||||
| bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-posix32"; | |||||
| break; | break; | ||||
| case BINARY_POSIX64: | case BINARY_POSIX64: | ||||
| bridgeBinary += OS_SEP_STR "carla-bridge-posix64"; | |||||
| bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-posix64"; | |||||
| break; | break; | ||||
| case BINARY_WIN32: | case BINARY_WIN32: | ||||
| bridgeBinary += OS_SEP_STR "carla-bridge-win32.exe"; | |||||
| bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-win32.exe"; | |||||
| break; | break; | ||||
| case BINARY_WIN64: | case BINARY_WIN64: | ||||
| bridgeBinary += OS_SEP_STR "carla-bridge-win64.exe"; | |||||
| bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-win64.exe"; | |||||
| break; | break; | ||||
| default: | default: | ||||
| bridgeBinary.clear(); | bridgeBinary.clear(); | ||||
| @@ -245,7 +245,8 @@ EngineTimeInfo::EngineTimeInfo() noexcept | |||||
| : playing(false), | : playing(false), | ||||
| frame(0), | frame(0), | ||||
| usecs(0), | usecs(0), | ||||
| valid(0x0) {} | |||||
| valid(0x0), | |||||
| bbt() {} | |||||
| void EngineTimeInfo::clear() noexcept | void EngineTimeInfo::clear() noexcept | ||||
| { | { | ||||
| @@ -85,9 +85,26 @@ const char* getCarlaRackFullPortNameFromId(const /*RackGraphCarlaPortIds*/ uint | |||||
| return nullptr; | 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 | ||||
| RackGraph::MIDI::MIDI() noexcept | |||||
| : ins(), | |||||
| outs() {} | |||||
| const char* RackGraph::MIDI::getName(const bool isInput, const uint portId) const noexcept | const char* RackGraph::MIDI::getName(const bool isInput, const uint portId) const noexcept | ||||
| { | { | ||||
| for (LinkedList<PortNameToId>::Itenerator it = isInput ? ins.begin() : outs.begin(); it.valid(); it.next()) | for (LinkedList<PortNameToId>::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::RackGraph(const uint32_t bufferSize, const uint32_t ins, const uint32_t outs) noexcept | RackGraph::RackGraph(const uint32_t bufferSize, const uint32_t ins, const uint32_t outs) noexcept | ||||
| : inputs(ins), | |||||
| : connections(), | |||||
| inputs(ins), | |||||
| outputs(outs), | outputs(outs), | ||||
| isOffline(false) | |||||
| isOffline(false), | |||||
| retCon(), | |||||
| audio(), | |||||
| midi() | |||||
| { | { | ||||
| audio.inBuf[0] = audio.inBuf[1] = nullptr; | audio.inBuf[0] = audio.inBuf[1] = nullptr; | ||||
| audio.inBufTmp[0] = audio.inBufTmp[1] = nullptr; | audio.inBufTmp[0] = audio.inBufTmp[1] = nullptr; | ||||
| @@ -76,6 +76,10 @@ struct RackGraph { | |||||
| float* inBuf[2]; | float* inBuf[2]; | ||||
| float* inBufTmp[2]; | float* inBufTmp[2]; | ||||
| float* outBuf[2]; | float* outBuf[2]; | ||||
| // c++ compat stuff | |||||
| Audio() noexcept; | |||||
| CARLA_PREVENT_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_CLASS(Audio) | |||||
| } audio; | } audio; | ||||
| struct MIDI { | struct MIDI { | ||||
| @@ -83,6 +87,10 @@ struct RackGraph { | |||||
| LinkedList<PortNameToId> outs; | LinkedList<PortNameToId> outs; | ||||
| const char* getName(const bool isInput, const uint portId) const noexcept; | 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; | 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; | } midi; | ||||
| RackGraph(const uint32_t bufferSize, const uint32_t inputs, const uint32_t outputs) noexcept; | RackGraph(const uint32_t bufferSize, const uint32_t inputs, const uint32_t outputs) noexcept; | ||||
| @@ -67,7 +67,8 @@ EngineInternalTime::EngineInternalTime() noexcept | |||||
| EngineNextAction::EngineNextAction() noexcept | EngineNextAction::EngineNextAction() noexcept | ||||
| : opcode(kEnginePostActionNull), | : opcode(kEnginePostActionNull), | ||||
| pluginId(0), | pluginId(0), | ||||
| value(0) {} | |||||
| value(0), | |||||
| waitEvent() {} | |||||
| EngineNextAction::~EngineNextAction() noexcept | EngineNextAction::~EngineNextAction() noexcept | ||||
| { | { | ||||
| @@ -105,15 +106,25 @@ CarlaEngine::ProtectedData::ProtectedData(CarlaEngine* const engine) noexcept | |||||
| isIdling(0), | isIdling(0), | ||||
| curPluginCount(0), | curPluginCount(0), | ||||
| maxPluginNumber(0), | maxPluginNumber(0), | ||||
| #ifndef BUILD_BRIDGE | |||||
| nextPluginId(0), | 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); | carla_zeroStruct(plugins, 1); | ||||
| } | |||||
| #endif | #endif | ||||
| } | |||||
| CarlaEngine::ProtectedData::~ProtectedData() noexcept | CarlaEngine::ProtectedData::~ProtectedData() noexcept | ||||
| { | { | ||||
| @@ -26,6 +26,9 @@ | |||||
| using juce::Atomic; | using juce::Atomic; | ||||
| using juce::WaitableEvent; | using juce::WaitableEvent; | ||||
| // FIXME only use CARLA_PREVENT_HEAP_ALLOCATION for structs | |||||
| // maybe separate macro | |||||
| CARLA_BACKEND_START_NAMESPACE | CARLA_BACKEND_START_NAMESPACE | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -87,6 +90,7 @@ private: | |||||
| PatchbayGraph* fPatchbay; | PatchbayGraph* fPatchbay; | ||||
| }; | }; | ||||
| CARLA_PREVENT_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalGraph) | CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalGraph) | ||||
| }; | }; | ||||
| #endif | #endif | ||||
| @@ -73,7 +73,8 @@ public: | |||||
| : CarlaEngineAudioPort(client, isInputPort), | : CarlaEngineAudioPort(client, isInputPort), | ||||
| fJackClient(jackClient), | fJackClient(jackClient), | ||||
| fJackPort(jackPort), | fJackPort(jackPort), | ||||
| kDeletionCallback(delCallback) | |||||
| kDeletionCallback(delCallback), | |||||
| leakDetector_CarlaEngineJackAudioPort() | |||||
| { | { | ||||
| carla_debug("CarlaEngineJackAudioPort::CarlaEngineJackAudioPort(%s, %p, %p)", bool2str(isInputPort), jackClient, jackPort); | carla_debug("CarlaEngineJackAudioPort::CarlaEngineJackAudioPort(%s, %p, %p)", bool2str(isInputPort), jackClient, jackPort); | ||||
| @@ -163,7 +164,8 @@ public: | |||||
| : CarlaEngineCVPort(client, isInputPort), | : CarlaEngineCVPort(client, isInputPort), | ||||
| fJackClient(jackClient), | fJackClient(jackClient), | ||||
| fJackPort(jackPort), | fJackPort(jackPort), | ||||
| kDeletionCallback(delCallback) | |||||
| kDeletionCallback(delCallback), | |||||
| leakDetector_CarlaEngineJackCVPort() | |||||
| { | { | ||||
| carla_debug("CarlaEngineJackCVPort::CarlaEngineJackCVPort(%s, %p, %p)", bool2str(isInputPort), jackClient, jackPort); | carla_debug("CarlaEngineJackCVPort::CarlaEngineJackCVPort(%s, %p, %p)", bool2str(isInputPort), jackClient, jackPort); | ||||
| @@ -252,7 +254,9 @@ public: | |||||
| fJackClient(jackClient), | fJackClient(jackClient), | ||||
| fJackPort(jackPort), | fJackPort(jackPort), | ||||
| fJackBuffer(nullptr), | fJackBuffer(nullptr), | ||||
| kDeletionCallback(delCallback) | |||||
| fRetEvent(kFallbackJackEngineEvent), | |||||
| kDeletionCallback(delCallback), | |||||
| leakDetector_CarlaEngineJackEventPort() | |||||
| { | { | ||||
| carla_debug("CarlaEngineJackEventPort::CarlaEngineJackEventPort(%s, %p, %p)", bool2str(isInputPort), jackClient, jackPort); | 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) | CarlaEngineJackClient(const CarlaEngine& engine, jack_client_t* const jackClient) | ||||
| : CarlaEngineClient(engine), | : CarlaEngineClient(engine), | ||||
| fJackClient(jackClient), | 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); | carla_debug("CarlaEngineJackClient::CarlaEngineJackClient(%p)", jackClient); | ||||
| @@ -619,11 +627,18 @@ public: | |||||
| CarlaEngineJack() | CarlaEngineJack() | ||||
| : CarlaEngine(), | : CarlaEngine(), | ||||
| fClient(nullptr), | fClient(nullptr), | ||||
| fTransportPos(), | |||||
| fTransportState(JackTransportStopped), | fTransportState(JackTransportStopped), | ||||
| fFreewheel(false) | |||||
| fFreewheel(false), | |||||
| #ifdef BUILD_BRIDGE | #ifdef BUILD_BRIDGE | ||||
| , fIsRunning(false) | |||||
| fIsRunning(false), | |||||
| #else | |||||
| fUsedGroups(), | |||||
| fUsedPorts(), | |||||
| fUsedConnections(), | |||||
| fNewGroups(), | |||||
| #endif | #endif | ||||
| leakDetector_CarlaEngineJack() | |||||
| { | { | ||||
| carla_debug("CarlaEngineJack::CarlaEngineJack()"); | carla_debug("CarlaEngineJack::CarlaEngineJack()"); | ||||
| @@ -54,7 +54,8 @@ class CarlaEngineNativeUI : public CarlaExternalUI | |||||
| { | { | ||||
| public: | public: | ||||
| CarlaEngineNativeUI(CarlaEngine* const engine) | CarlaEngineNativeUI(CarlaEngine* const engine) | ||||
| : fEngine(engine) | |||||
| : fEngine(engine), | |||||
| leakDetector_CarlaEngineNativeUI() | |||||
| { | { | ||||
| carla_debug("CarlaEngineNativeUI::CarlaEngineNativeUI(%p)", engine); | carla_debug("CarlaEngineNativeUI::CarlaEngineNativeUI(%p)", engine); | ||||
| } | } | ||||
| @@ -555,7 +556,8 @@ public: | |||||
| fIsPatchbay(isPatchbay), | fIsPatchbay(isPatchbay), | ||||
| fIsActive(false), | fIsActive(false), | ||||
| fIsRunning(false), | fIsRunning(false), | ||||
| fUiServer(this) | |||||
| fUiServer(this), | |||||
| leakDetector_CarlaEngineNative() | |||||
| { | { | ||||
| carla_debug("CarlaEngineNative::CarlaEngineNative()"); | carla_debug("CarlaEngineNative::CarlaEngineNative()"); | ||||
| @@ -41,8 +41,15 @@ extern int CarlaPluginSetOscBridgeInfo(CarlaPlugin* const plugin, const PluginBr | |||||
| CarlaEngineOsc::CarlaEngineOsc(CarlaEngine* const engine) noexcept | CarlaEngineOsc::CarlaEngineOsc(CarlaEngine* const engine) noexcept | ||||
| : fEngine(engine), | : fEngine(engine), | ||||
| #ifndef BUILD_BRIDGE | |||||
| fControlData(), | |||||
| #endif | |||||
| fName(), | |||||
| fServerPathTCP(), | |||||
| fServerPathUDP(), | |||||
| fServerTCP(nullptr), | fServerTCP(nullptr), | ||||
| fServerUDP(nullptr) | |||||
| fServerUDP(nullptr), | |||||
| leakDetector_CarlaEngineOsc() | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT(engine != nullptr); | CARLA_SAFE_ASSERT(engine != nullptr); | ||||
| carla_debug("CarlaEngineOsc::CarlaEngineOsc(%p)", engine); | carla_debug("CarlaEngineOsc::CarlaEngineOsc(%p)", engine); | ||||
| @@ -93,6 +93,10 @@ public: | |||||
| private: | private: | ||||
| CarlaEngine* const fEngine; | CarlaEngine* const fEngine; | ||||
| #ifndef BUILD_BRIDGE | |||||
| CarlaOscData fControlData; // for carla-control | |||||
| #endif | |||||
| CarlaString fName; | CarlaString fName; | ||||
| CarlaString fServerPathTCP; | CarlaString fServerPathTCP; | ||||
| @@ -100,10 +104,6 @@ private: | |||||
| lo_server fServerTCP; | lo_server fServerTCP; | ||||
| lo_server fServerUDP; | 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); | 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); | ||||
| @@ -157,7 +157,13 @@ public: | |||||
| fAudioInCount(0), | fAudioInCount(0), | ||||
| fAudioOutCount(0), | fAudioOutCount(0), | ||||
| fLastEventTime(0), | fLastEventTime(0), | ||||
| fMidiOutVector(3) | |||||
| fDeviceName(), | |||||
| fMidiIns(), | |||||
| fMidiInEvents(), | |||||
| fMidiOuts(), | |||||
| fMidiOutMutex(), | |||||
| fMidiOutVector(3), | |||||
| leakDetector_CarlaEngineRtAudio() | |||||
| { | { | ||||
| carla_debug("CarlaEngineRtAudio::CarlaEngineRtAudio(%i)", api); | carla_debug("CarlaEngineRtAudio::CarlaEngineRtAudio(%i)", api); | ||||
| @@ -949,7 +955,8 @@ private: | |||||
| RtLinkedList<RtMidiEvent> dataPending; | RtLinkedList<RtMidiEvent> dataPending; | ||||
| RtMidiEvents() | RtMidiEvents() | ||||
| : dataPool(512, 512), | |||||
| : mutex(), | |||||
| dataPool(512, 512), | |||||
| data(dataPool), | data(dataPool), | ||||
| dataPending(dataPool) {} | dataPending(dataPool) {} | ||||
| @@ -25,7 +25,8 @@ CARLA_BACKEND_START_NAMESPACE | |||||
| CarlaEngineThread::CarlaEngineThread(CarlaEngine* const engine) noexcept | CarlaEngineThread::CarlaEngineThread(CarlaEngine* const engine) noexcept | ||||
| : CarlaThread("CarlaEngineThread"), | : CarlaThread("CarlaEngineThread"), | ||||
| kEngine(engine) | |||||
| kEngine(engine), | |||||
| leakDetector_CarlaEngineThread() | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT(engine != nullptr); | CARLA_SAFE_ASSERT(engine != nullptr); | ||||
| carla_debug("CarlaEngineThread::CarlaEngineThread(%p)", engine); | carla_debug("CarlaEngineThread::CarlaEngineThread(%p)", engine); | ||||
| @@ -200,40 +200,51 @@ private: \ | |||||
| #ifdef CARLA_PROPER_CPP11_SUPPORT | #ifdef CARLA_PROPER_CPP11_SUPPORT | ||||
| # define CARLA_PREVENT_HEAP_ALLOCATION \ | # define CARLA_PREVENT_HEAP_ALLOCATION \ | ||||
| private: \ | private: \ | ||||
| static void* operator new(size_t) = delete; \ | |||||
| static void* operator new(std::size_t) = delete; \ | |||||
| static void operator delete(void*) = delete; | static void operator delete(void*) = delete; | ||||
| #else | #else | ||||
| # define CARLA_PREVENT_HEAP_ALLOCATION \ | # define CARLA_PREVENT_HEAP_ALLOCATION \ | ||||
| private: \ | private: \ | ||||
| static void* operator new(size_t); \ | |||||
| static void* operator new(std::size_t); \ | |||||
| static void operator delete(void*); | static void operator delete(void*); | ||||
| #endif | #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 | #ifdef __cplusplus | ||||
| # define EXTERN_C extern "C" | |||||
| # define CARLA_EXTERN_C extern "C" | |||||
| #else | #else | ||||
| # define EXTERN_C | |||||
| # define CARLA_EXTERN_C | |||||
| #endif | #endif | ||||
| /* Define CARLA_EXPORT */ | /* Define CARLA_EXPORT */ | ||||
| #ifdef BUILD_BRIDGE | #ifdef BUILD_BRIDGE | ||||
| # define CARLA_EXPORT EXTERN_C | |||||
| # define CARLA_EXPORT CARLA_EXTERN_C | |||||
| #else | #else | ||||
| # if defined(CARLA_OS_WIN) && ! defined(__WINE__) | # if defined(CARLA_OS_WIN) && ! defined(__WINE__) | ||||
| # define CARLA_EXPORT EXTERN_C __declspec (dllexport) | |||||
| # define CARLA_EXPORT CARLA_EXTERN_C __declspec (dllexport) | |||||
| # else | # else | ||||
| # define CARLA_EXPORT EXTERN_C __attribute__ ((visibility("default"))) | |||||
| # define CARLA_EXPORT CARLA_EXTERN_C __attribute__ ((visibility("default"))) | |||||
| # endif | # endif | ||||
| #endif | #endif | ||||
| /* Define OS_SEP */ | /* Define OS_SEP */ | ||||
| #ifdef CARLA_OS_WIN | #ifdef CARLA_OS_WIN | ||||
| # define OS_SEP '\\' | |||||
| # define OS_SEP_STR "\\" | |||||
| # define CARLA_OS_SEP '\\' | |||||
| # define CARLA_OS_SEP_STR "\\" | |||||
| #else | #else | ||||
| # define OS_SEP '/' | |||||
| # define OS_SEP_STR "/" | |||||
| # define CARLA_OS_SEP '/' | |||||
| # define CARLA_OS_SEP_STR "/" | |||||
| #endif | #endif | ||||
| /* Useful typedefs */ | /* Useful typedefs */ | ||||
| @@ -121,6 +121,8 @@ static void test_CarlaUtils() | |||||
| str4 = nullptr; | str4 = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| CARLA_DECLARE_NON_COPY_STRUCT(TestStruct) | |||||
| }; | }; | ||||
| TestStruct a, b, c; | TestStruct a, b, c; | ||||
| @@ -30,8 +30,9 @@ | |||||
| class LeakTestClass | class LeakTestClass | ||||
| { | { | ||||
| public: | public: | ||||
| LeakTestClass()noexcept | |||||
| : i(0) {} | |||||
| LeakTestClass() noexcept | |||||
| : i(0), | |||||
| leakDetector_LeakTestClass() {} | |||||
| private: | private: | ||||
| int i; | int i; | ||||
| @@ -56,6 +56,9 @@ public: | |||||
| private: | private: | ||||
| const magic_t fMagic; | const magic_t fMagic; | ||||
| CARLA_PREVENT_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_STRUCT(CarlaMagic) | |||||
| }; | }; | ||||
| static const CarlaMagic& getCarlaMagicInstance() | static const CarlaMagic& getCarlaMagicInstance() | ||||
| @@ -33,9 +33,11 @@ public: | |||||
| }; | }; | ||||
| CarlaExternalUI() | CarlaExternalUI() | ||||
| : fUiState(UiNone) | |||||
| { | |||||
| } | |||||
| : fFilename(), | |||||
| fSampleRate(), | |||||
| fUiTitle(), | |||||
| fUiState(UiNone), | |||||
| leakDetector_CarlaExternalUI() {} | |||||
| ~CarlaExternalUI() override | ~CarlaExternalUI() override | ||||
| { | { | ||||
| @@ -45,7 +45,7 @@ | |||||
| #define CARLA_LEAK_DETECTOR(ClassName) \ | #define CARLA_LEAK_DETECTOR(ClassName) \ | ||||
| friend class ::LeakedObjectDetector<ClassName>; \ | friend class ::LeakedObjectDetector<ClassName>; \ | ||||
| static const char* getLeakedObjectClassName() noexcept { return #ClassName; } \ | static const char* getLeakedObjectClassName() noexcept { return #ClassName; } \ | ||||
| ::LeakedObjectDetector<ClassName> CARLA_JOIN_MACRO(leakDetector, __LINE__); | |||||
| ::LeakedObjectDetector<ClassName> CARLA_JOIN_MACRO(leakDetector_, ClassName); | |||||
| #define CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ClassName) \ | #define CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ClassName) \ | ||||
| CARLA_DECLARE_NON_COPY_CLASS(ClassName) \ | CARLA_DECLARE_NON_COPY_CLASS(ClassName) \ | ||||
| @@ -96,9 +96,7 @@ private: | |||||
| { | { | ||||
| public: | public: | ||||
| LeakCounter() noexcept | LeakCounter() noexcept | ||||
| { | |||||
| numObjects = 0; | |||||
| } | |||||
| : numObjects(0) {} | |||||
| ~LeakCounter() noexcept | ~LeakCounter() noexcept | ||||
| { | { | ||||
| @@ -27,7 +27,9 @@ | |||||
| class LibCounter | class LibCounter | ||||
| { | { | ||||
| public: | public: | ||||
| LibCounter() noexcept {} | |||||
| LibCounter() noexcept | |||||
| : fMutex(), | |||||
| fLibs() {} | |||||
| ~LibCounter() noexcept | ~LibCounter() noexcept | ||||
| { | { | ||||
| @@ -429,7 +429,7 @@ public: | |||||
| return cState; | return cState; | ||||
| } | } | ||||
| CARLA_PREVENT_HEAP_ALLOCATION | |||||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||||
| }; | }; | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -32,7 +32,8 @@ public: | |||||
| * Constructor. | * Constructor. | ||||
| */ | */ | ||||
| CarlaMutex() noexcept | CarlaMutex() noexcept | ||||
| : fTryLockWasCalled(false) | |||||
| : fMutex(), | |||||
| fTryLockWasCalled(false) | |||||
| { | { | ||||
| pthread_mutex_init(&fMutex, nullptr); | pthread_mutex_init(&fMutex, nullptr); | ||||
| } | } | ||||
| @@ -103,6 +104,11 @@ public: | |||||
| * Constructor. | * Constructor. | ||||
| */ | */ | ||||
| CarlaRecursiveMutex() noexcept | CarlaRecursiveMutex() noexcept | ||||
| #ifdef CARLA_OS_WIN | |||||
| : fSection() | |||||
| #else | |||||
| : fMutex() | |||||
| #endif | |||||
| { | { | ||||
| #ifdef CARLA_OS_WIN | #ifdef CARLA_OS_WIN | ||||
| InitializeCriticalSection(&fSection); | InitializeCriticalSection(&fSection); | ||||
| @@ -66,7 +66,8 @@ struct PatchbayGroupList { | |||||
| LinkedList<GroupNameToId> list; | LinkedList<GroupNameToId> list; | ||||
| PatchbayGroupList() noexcept | PatchbayGroupList() noexcept | ||||
| : lastId(0) {} | |||||
| : lastId(0), | |||||
| list() {} | |||||
| void clear() noexcept | void clear() noexcept | ||||
| { | { | ||||
| @@ -159,7 +160,8 @@ struct PatchbayPortList { | |||||
| LinkedList<PortNameToId> list; | LinkedList<PortNameToId> list; | ||||
| PatchbayPortList() noexcept | PatchbayPortList() noexcept | ||||
| : lastId(0) {} | |||||
| : lastId(0), | |||||
| list() {} | |||||
| void clear() noexcept | void clear() noexcept | ||||
| { | { | ||||
| @@ -247,7 +249,8 @@ struct PatchbayConnectionList { | |||||
| LinkedList<ConnectionToId> list; | LinkedList<ConnectionToId> list; | ||||
| PatchbayConnectionList() noexcept | PatchbayConnectionList() noexcept | ||||
| : lastId(0) {} | |||||
| : lastId(0), | |||||
| list() {} | |||||
| void clear() noexcept | void clear() noexcept | ||||
| { | { | ||||
| @@ -39,10 +39,12 @@ class CarlaPipeServer | |||||
| { | { | ||||
| protected: | protected: | ||||
| CarlaPipeServer() | CarlaPipeServer() | ||||
| : fPipeRecv(-1), | |||||
| : fWriteLock(), | |||||
| fPipeRecv(-1), | |||||
| fPipeSend(-1), | fPipeSend(-1), | ||||
| fIsReading(false), | fIsReading(false), | ||||
| fPid(-1) | |||||
| fPid(-1), | |||||
| fTmpStr() | |||||
| { | { | ||||
| carla_debug("CarlaPipeServer::CarlaPipeServer()"); | carla_debug("CarlaPipeServer::CarlaPipeServer()"); | ||||
| @@ -41,10 +41,10 @@ static int temporaryErrorHandler(Display*, XErrorEvent*) | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| class X11PluginUi : public CarlaPluginUI | |||||
| class X11PluginUI : public CarlaPluginUI | |||||
| { | { | ||||
| public: | public: | ||||
| X11PluginUi(CloseCallback* const cb, const uintptr_t parentId) noexcept | |||||
| X11PluginUI(CloseCallback* const cb, const uintptr_t parentId) noexcept | |||||
| : CarlaPluginUI(cb), | : CarlaPluginUI(cb), | ||||
| fDisplay(nullptr), | fDisplay(nullptr), | ||||
| fWindow(0), | fWindow(0), | ||||
| @@ -88,7 +88,7 @@ public: | |||||
| setTransientWinId(parentId); | setTransientWinId(parentId); | ||||
| } | } | ||||
| ~X11PluginUi() override | |||||
| ~X11PluginUI() override | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT(! fIsVisible); | CARLA_SAFE_ASSERT(! fIsVisible); | ||||
| @@ -293,6 +293,8 @@ private: | |||||
| bool fIsVisible; | bool fIsVisible; | ||||
| bool fFirstShow; | bool fFirstShow; | ||||
| EventProcPtr fEventProc; | EventProcPtr fEventProc; | ||||
| CARLA_DECLARE_NON_COPY_CLASS(X11PluginUI) | |||||
| }; | }; | ||||
| #endif | #endif | ||||
| @@ -314,6 +316,9 @@ bool CarlaPluginUI::tryTransientWinIdMatch(const uintptr_t pid, const char* cons | |||||
| Display* display; | Display* display; | ||||
| ScopedDisplay() : display(XOpenDisplay(nullptr)) {} | ScopedDisplay() : display(XOpenDisplay(nullptr)) {} | ||||
| ~ScopedDisplay() { if (display!=nullptr) XCloseDisplay(display); } | ~ScopedDisplay() { if (display!=nullptr) XCloseDisplay(display); } | ||||
| // c++ compat stuff | |||||
| CARLA_PREVENT_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_CLASS(ScopedDisplay) | |||||
| }; | }; | ||||
| struct ScopedFreeData { | struct ScopedFreeData { | ||||
| union { | union { | ||||
| @@ -323,6 +328,9 @@ bool CarlaPluginUI::tryTransientWinIdMatch(const uintptr_t pid, const char* cons | |||||
| ScopedFreeData(char* d) : data(d) {} | ScopedFreeData(char* d) : data(d) {} | ||||
| ScopedFreeData(uchar* d) : udata(d) {} | ScopedFreeData(uchar* d) : udata(d) {} | ||||
| ~ScopedFreeData() { XFree(data); } | ~ScopedFreeData() { XFree(data); } | ||||
| // c++ compat stuff | |||||
| CARLA_PREVENT_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_CLASS(ScopedFreeData) | |||||
| }; | }; | ||||
| const ScopedDisplay sd; | const ScopedDisplay sd; | ||||
| @@ -502,7 +510,7 @@ CarlaPluginUI* CarlaPluginUI::newWindows(CloseCallback*, uintptr_t) | |||||
| #ifdef HAVE_X11 | #ifdef HAVE_X11 | ||||
| CarlaPluginUI* CarlaPluginUI::newX11(CloseCallback* cb, uintptr_t parentId) | CarlaPluginUI* CarlaPluginUI::newX11(CloseCallback* cb, uintptr_t parentId) | ||||
| { | { | ||||
| return new X11PluginUi(cb, parentId); | |||||
| return new X11PluginUI(cb, parentId); | |||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -60,6 +60,8 @@ protected: | |||||
| bool fIsIdling; | bool fIsIdling; | ||||
| CloseCallback* fCallback; | CloseCallback* fCallback; | ||||
| CarlaPluginUI(CloseCallback* const cb) noexcept : fIsIdling(false), fCallback(cb) {} | CarlaPluginUI(CloseCallback* const cb) noexcept : fIsIdling(false), fCallback(cb) {} | ||||
| CARLA_DECLARE_NON_COPY_CLASS(CarlaPluginUI) | |||||
| }; | }; | ||||
| // ----------------------------------------------------- | // ----------------------------------------------------- | ||||
| @@ -75,6 +75,9 @@ struct BigStackBuffer { | |||||
| uint8_t buf[size]; | uint8_t buf[size]; | ||||
| }; | }; | ||||
| #define HeapBuffer_INIT {0, 0, 0, 0, false, nullptr} | |||||
| #define StackBuffer_INIT {0, 0, 0, false, {0}} | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // CarlaRingBuffer templated class | // CarlaRingBuffer templated class | ||||
| @@ -85,12 +88,9 @@ public: | |||||
| CarlaRingBuffer() noexcept | CarlaRingBuffer() noexcept | ||||
| : fBuffer(nullptr) {} | : fBuffer(nullptr) {} | ||||
| CarlaRingBuffer(BufferStruct* const ringBuf) noexcept | |||||
| : fBuffer(ringBuf) | |||||
| { | |||||
| if (ringBuf != nullptr) | |||||
| clear(); | |||||
| } | |||||
| virtual ~CarlaRingBuffer() noexcept {} | |||||
| // ------------------------------------------------------------------- | |||||
| void clear() noexcept | void clear() noexcept | ||||
| { | { | ||||
| @@ -376,7 +376,7 @@ protected: | |||||
| private: | private: | ||||
| BufferStruct* fBuffer; | BufferStruct* fBuffer; | ||||
| CARLA_PREVENT_HEAP_ALLOCATION | |||||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_CLASS(CarlaRingBuffer) | CARLA_DECLARE_NON_COPY_CLASS(CarlaRingBuffer) | ||||
| }; | }; | ||||
| @@ -387,12 +387,9 @@ class CarlaHeapRingBuffer : public CarlaRingBuffer<HeapBuffer> | |||||
| { | { | ||||
| public: | public: | ||||
| CarlaHeapRingBuffer() noexcept | CarlaHeapRingBuffer() noexcept | ||||
| : CarlaRingBuffer<HeapBuffer>() | |||||
| { | |||||
| carla_zeroStruct(fHeapBuffer); | |||||
| } | |||||
| : fHeapBuffer(HeapBuffer_INIT) {} | |||||
| ~CarlaHeapRingBuffer() noexcept | |||||
| ~CarlaHeapRingBuffer() noexcept override | |||||
| { | { | ||||
| if (fHeapBuffer.buf == nullptr) | if (fHeapBuffer.buf == nullptr) | ||||
| return; | return; | ||||
| @@ -430,7 +427,7 @@ public: | |||||
| private: | private: | ||||
| HeapBuffer fHeapBuffer; | HeapBuffer fHeapBuffer; | ||||
| CARLA_PREVENT_HEAP_ALLOCATION | |||||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_CLASS(CarlaHeapRingBuffer) | CARLA_DECLARE_NON_COPY_CLASS(CarlaHeapRingBuffer) | ||||
| }; | }; | ||||
| @@ -441,12 +438,15 @@ class CarlaStackRingBuffer : public CarlaRingBuffer<StackBuffer> | |||||
| { | { | ||||
| public: | public: | ||||
| CarlaStackRingBuffer() noexcept | CarlaStackRingBuffer() noexcept | ||||
| : CarlaRingBuffer<StackBuffer>(&fStackBuffer) {} | |||||
| : fStackBuffer(StackBuffer_INIT) | |||||
| { | |||||
| setRingBuffer(&fStackBuffer, false); | |||||
| } | |||||
| private: | private: | ||||
| StackBuffer fStackBuffer; | StackBuffer fStackBuffer; | ||||
| CARLA_PREVENT_HEAP_ALLOCATION | |||||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_CLASS(CarlaStackRingBuffer) | CARLA_DECLARE_NON_COPY_CLASS(CarlaStackRingBuffer) | ||||
| }; | }; | ||||
| @@ -152,7 +152,9 @@ StateSave::StateSave() noexcept | |||||
| currentProgramName(nullptr), | currentProgramName(nullptr), | ||||
| currentMidiBank(-1), | currentMidiBank(-1), | ||||
| currentMidiProgram(-1), | currentMidiProgram(-1), | ||||
| chunk(nullptr) {} | |||||
| chunk(nullptr), | |||||
| parameters(), | |||||
| customData() {} | |||||
| StateSave::~StateSave() noexcept | StateSave::~StateSave() noexcept | ||||
| { | { | ||||
| @@ -40,20 +40,20 @@ public: | |||||
| * Empty string. | * Empty string. | ||||
| */ | */ | ||||
| explicit CarlaString() noexcept | explicit CarlaString() noexcept | ||||
| { | |||||
| _init(); | |||||
| } | |||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) {} | |||||
| /* | /* | ||||
| * Simple character. | * Simple character. | ||||
| */ | */ | ||||
| explicit CarlaString(const char c) noexcept | explicit CarlaString(const char c) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| char ch[2]; | char ch[2]; | ||||
| ch[0] = c; | ch[0] = c; | ||||
| ch[1] = '\0'; | ch[1] = '\0'; | ||||
| _init(); | |||||
| _dup(ch); | _dup(ch); | ||||
| } | } | ||||
| @@ -61,8 +61,9 @@ public: | |||||
| * Simple char string. | * Simple char string. | ||||
| */ | */ | ||||
| explicit CarlaString(char* const strBuf) noexcept | explicit CarlaString(char* const strBuf) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| _init(); | |||||
| _dup(strBuf); | _dup(strBuf); | ||||
| } | } | ||||
| @@ -70,8 +71,9 @@ public: | |||||
| * Simple const char string. | * Simple const char string. | ||||
| */ | */ | ||||
| explicit CarlaString(const char* const strBuf) noexcept | explicit CarlaString(const char* const strBuf) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| _init(); | |||||
| _dup(strBuf); | _dup(strBuf); | ||||
| } | } | ||||
| @@ -79,12 +81,13 @@ public: | |||||
| * Integer. | * Integer. | ||||
| */ | */ | ||||
| explicit CarlaString(const int value) noexcept | explicit CarlaString(const int value) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| char strBuf[0xff+1]; | char strBuf[0xff+1]; | ||||
| std::snprintf(strBuf, 0xff, "%d", value); | std::snprintf(strBuf, 0xff, "%d", value); | ||||
| strBuf[0xff] = '\0'; | strBuf[0xff] = '\0'; | ||||
| _init(); | |||||
| _dup(strBuf); | _dup(strBuf); | ||||
| } | } | ||||
| @@ -92,12 +95,13 @@ public: | |||||
| * Unsigned integer, possibly in hexadecimal. | * Unsigned integer, possibly in hexadecimal. | ||||
| */ | */ | ||||
| explicit CarlaString(const unsigned int value, const bool hexadecimal = false) noexcept | explicit CarlaString(const unsigned int value, const bool hexadecimal = false) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| char strBuf[0xff+1]; | char strBuf[0xff+1]; | ||||
| std::snprintf(strBuf, 0xff, hexadecimal ? "0x%x" : "%u", value); | std::snprintf(strBuf, 0xff, hexadecimal ? "0x%x" : "%u", value); | ||||
| strBuf[0xff] = '\0'; | strBuf[0xff] = '\0'; | ||||
| _init(); | |||||
| _dup(strBuf); | _dup(strBuf); | ||||
| } | } | ||||
| @@ -105,12 +109,13 @@ public: | |||||
| * Long integer. | * Long integer. | ||||
| */ | */ | ||||
| explicit CarlaString(const long value) noexcept | explicit CarlaString(const long value) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| char strBuf[0xff+1]; | char strBuf[0xff+1]; | ||||
| std::snprintf(strBuf, 0xff, "%ld", value); | std::snprintf(strBuf, 0xff, "%ld", value); | ||||
| strBuf[0xff] = '\0'; | strBuf[0xff] = '\0'; | ||||
| _init(); | |||||
| _dup(strBuf); | _dup(strBuf); | ||||
| } | } | ||||
| @@ -118,12 +123,13 @@ public: | |||||
| * Long unsigned integer, possibly hexadecimal. | * Long unsigned integer, possibly hexadecimal. | ||||
| */ | */ | ||||
| explicit CarlaString(const unsigned long value, const bool hexadecimal = false) noexcept | explicit CarlaString(const unsigned long value, const bool hexadecimal = false) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| char strBuf[0xff+1]; | char strBuf[0xff+1]; | ||||
| std::snprintf(strBuf, 0xff, hexadecimal ? "0x%lx" : "%lu", value); | std::snprintf(strBuf, 0xff, hexadecimal ? "0x%lx" : "%lu", value); | ||||
| strBuf[0xff] = '\0'; | strBuf[0xff] = '\0'; | ||||
| _init(); | |||||
| _dup(strBuf); | _dup(strBuf); | ||||
| } | } | ||||
| @@ -131,12 +137,13 @@ public: | |||||
| * Long long integer. | * Long long integer. | ||||
| */ | */ | ||||
| explicit CarlaString(const long long value) noexcept | explicit CarlaString(const long long value) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| char strBuf[0xff+1]; | char strBuf[0xff+1]; | ||||
| std::snprintf(strBuf, 0xff, "%lld", value); | std::snprintf(strBuf, 0xff, "%lld", value); | ||||
| strBuf[0xff] = '\0'; | strBuf[0xff] = '\0'; | ||||
| _init(); | |||||
| _dup(strBuf); | _dup(strBuf); | ||||
| } | } | ||||
| @@ -144,12 +151,13 @@ public: | |||||
| * Long long unsigned integer, possibly hexadecimal. | * Long long unsigned integer, possibly hexadecimal. | ||||
| */ | */ | ||||
| explicit CarlaString(const unsigned long long value, const bool hexadecimal = false) noexcept | explicit CarlaString(const unsigned long long value, const bool hexadecimal = false) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| char strBuf[0xff+1]; | char strBuf[0xff+1]; | ||||
| std::snprintf(strBuf, 0xff, hexadecimal ? "0x%llx" : "%llu", value); | std::snprintf(strBuf, 0xff, hexadecimal ? "0x%llx" : "%llu", value); | ||||
| strBuf[0xff] = '\0'; | strBuf[0xff] = '\0'; | ||||
| _init(); | |||||
| _dup(strBuf); | _dup(strBuf); | ||||
| } | } | ||||
| @@ -157,12 +165,13 @@ public: | |||||
| * Single-precision floating point number. | * Single-precision floating point number. | ||||
| */ | */ | ||||
| explicit CarlaString(const float value) noexcept | explicit CarlaString(const float value) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| char strBuf[0xff+1]; | char strBuf[0xff+1]; | ||||
| std::snprintf(strBuf, 0xff, "%f", value); | std::snprintf(strBuf, 0xff, "%f", value); | ||||
| strBuf[0xff] = '\0'; | strBuf[0xff] = '\0'; | ||||
| _init(); | |||||
| _dup(strBuf); | _dup(strBuf); | ||||
| } | } | ||||
| @@ -170,12 +179,13 @@ public: | |||||
| * Double-precision floating point number. | * Double-precision floating point number. | ||||
| */ | */ | ||||
| explicit CarlaString(const double value) noexcept | explicit CarlaString(const double value) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| char strBuf[0xff+1]; | char strBuf[0xff+1]; | ||||
| std::snprintf(strBuf, 0xff, "%g", value); | std::snprintf(strBuf, 0xff, "%g", value); | ||||
| strBuf[0xff] = '\0'; | strBuf[0xff] = '\0'; | ||||
| _init(); | |||||
| _dup(strBuf); | _dup(strBuf); | ||||
| } | } | ||||
| @@ -186,8 +196,9 @@ public: | |||||
| * Create string from another string. | * Create string from another string. | ||||
| */ | */ | ||||
| CarlaString(const CarlaString& str) noexcept | CarlaString(const CarlaString& str) noexcept | ||||
| : fBuffer(_null()), | |||||
| fBufferLen(0) | |||||
| { | { | ||||
| _init(); | |||||
| _dup(str.fBuffer); | _dup(str.fBuffer); | ||||
| } | } | ||||
| @@ -750,16 +761,6 @@ private: | |||||
| return &sNull; | return &sNull; | ||||
| } | } | ||||
| /* | |||||
| * Shared init function. | |||||
| * Called on all constructors. | |||||
| */ | |||||
| void _init() noexcept | |||||
| { | |||||
| fBuffer = _null(); | |||||
| fBufferLen = 0; | |||||
| } | |||||
| /* | /* | ||||
| * Helper function. | * Helper function. | ||||
| * Called whenever the string needs to be allocated. | * Called whenever the string needs to be allocated. | ||||
| @@ -783,7 +784,11 @@ private: | |||||
| fBuffer = (char*)std::malloc(fBufferLen+1); | fBuffer = (char*)std::malloc(fBufferLen+1); | ||||
| if (fBuffer == nullptr) | if (fBuffer == nullptr) | ||||
| return _init(); | |||||
| { | |||||
| fBuffer = _null(); | |||||
| fBufferLen = 0; | |||||
| return; | |||||
| } | |||||
| std::strcpy(fBuffer, strBuf); | std::strcpy(fBuffer, strBuf); | ||||
| @@ -800,7 +805,8 @@ private: | |||||
| CARLA_SAFE_ASSERT(fBuffer != nullptr); | CARLA_SAFE_ASSERT(fBuffer != nullptr); | ||||
| std::free(fBuffer); | std::free(fBuffer); | ||||
| _init(); | |||||
| fBuffer = _null(); | |||||
| fBufferLen = 0; | |||||
| } | } | ||||
| } | } | ||||
| @@ -18,7 +18,6 @@ | |||||
| #ifndef CARLA_STRING_LIST_HPP_INCLUDED | #ifndef CARLA_STRING_LIST_HPP_INCLUDED | ||||
| #define CARLA_STRING_LIST_HPP_INCLUDED | #define CARLA_STRING_LIST_HPP_INCLUDED | ||||
| #include "CarlaString.hpp" | |||||
| #include "LinkedList.hpp" | #include "LinkedList.hpp" | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -39,7 +38,7 @@ public: | |||||
| copy(ptr.fCharList); | copy(ptr.fCharList); | ||||
| } | } | ||||
| CharStringListPtr(const LinkedList<CarlaString>& list) noexcept | |||||
| CharStringListPtr(const LinkedList<const char*>& list) noexcept | |||||
| : fCharList(nullptr) | : fCharList(nullptr) | ||||
| { | { | ||||
| copy(list); | copy(list); | ||||
| @@ -50,6 +49,8 @@ public: | |||||
| clear(); | clear(); | ||||
| } | } | ||||
| // ------------------------------------------------------------------- | |||||
| operator const char* const*() const noexcept | operator const char* const*() const noexcept | ||||
| { | { | ||||
| return fCharList; | return fCharList; | ||||
| @@ -69,13 +70,15 @@ public: | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| CharStringListPtr& operator=(const LinkedList<CarlaString>& list) noexcept | |||||
| CharStringListPtr& operator=(const LinkedList<const char*>& list) noexcept | |||||
| { | { | ||||
| clear(); | clear(); | ||||
| copy(list); | copy(list); | ||||
| return *this; | return *this; | ||||
| } | } | ||||
| // ------------------------------------------------------------------- | |||||
| protected: | protected: | ||||
| void clear() noexcept | void clear() noexcept | ||||
| { | { | ||||
| @@ -119,7 +122,7 @@ protected: | |||||
| fCharList = tmpList; | fCharList = tmpList; | ||||
| } | } | ||||
| void copy(const LinkedList<CarlaString>& list) noexcept | |||||
| void copy(const LinkedList<const char*>& list) noexcept | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(fCharList == nullptr,); | CARLA_SAFE_ASSERT_RETURN(fCharList == nullptr,); | ||||
| @@ -133,23 +136,18 @@ protected: | |||||
| } CARLA_SAFE_EXCEPTION_RETURN("CharStringListPtr::copy",); | } CARLA_SAFE_EXCEPTION_RETURN("CharStringListPtr::copy",); | ||||
| size_t i=0; | size_t i=0; | ||||
| for (LinkedList<CarlaString>::Itenerator it = list.begin(); it.valid(); it.next(), ++i) | |||||
| for (LinkedList<const char*>::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; | tmpList[count] = nullptr; | ||||
| fCharList = tmpList; | fCharList = tmpList; | ||||
| } | } | ||||
| // ------------------------------------------------------------------- | |||||
| private: | private: | ||||
| const char* const* fCharList; | const char* const* fCharList; | ||||
| }; | }; | ||||
| @@ -157,50 +155,144 @@ private: | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // CarlaStringList | // CarlaStringList | ||||
| class CarlaStringList : public LinkedList<CarlaString> | |||||
| class CarlaStringList : public LinkedList<const char*> | |||||
| { | { | ||||
| public: | public: | ||||
| CarlaStringList() noexcept | CarlaStringList() noexcept | ||||
| : LinkedList<CarlaString>(true) {} | |||||
| : LinkedList<const char*>() {} | |||||
| #if 0 | |||||
| CarlaStringList(const CarlaStringList& list) noexcept | CarlaStringList(const CarlaStringList& list) noexcept | ||||
| : LinkedList<CarlaString>(true) | |||||
| : LinkedList<const char*>() | |||||
| { | { | ||||
| for (Itenerator it = list.begin(); it.valid(); it.next()) | for (Itenerator it = list.begin(); it.valid(); it.next()) | ||||
| LinkedList<CarlaString>::append(it.getValue()); | |||||
| LinkedList<const char*>::append(carla_strdup_safe(it.getValue())); | |||||
| } | } | ||||
| #endif | |||||
| ~CarlaStringList() noexcept | |||||
| ~CarlaStringList() noexcept override | |||||
| { | { | ||||
| clear(); | 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<const char*>::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<const char*>::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<const char*>::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<const char*>::insert(stringDup)) | |||||
| return true; | |||||
| delete[] stringDup; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| bool insertAt(const char* const string, const Itenerator& it) noexcept | |||||
| { | { | ||||
| const CarlaString string(strBuf); | |||||
| return LinkedList<CarlaString>::append(string); | |||||
| CARLA_SAFE_ASSERT_RETURN(string != nullptr, false); | |||||
| if (const char* const stringDup = carla_strdup_safe(string)) | |||||
| { | |||||
| if (LinkedList<const char*>::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<CarlaString>::appendAt(string, it); | |||||
| if (const char* const string = it.getValue()) | |||||
| delete[] string; | |||||
| LinkedList<const char*>::remove(it); | |||||
| } | } | ||||
| bool insert(const char* const strBuf) noexcept | |||||
| bool removeOne(const char* const string) noexcept | |||||
| { | { | ||||
| const CarlaString string(strBuf); | |||||
| return LinkedList<CarlaString>::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<const char*>::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<CarlaString>::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<const char*>::remove(it); | |||||
| } | |||||
| } | } | ||||
| // ------------------------------------------------------------------- | |||||
| CharStringListPtr toCharStringListPtr() const noexcept | CharStringListPtr toCharStringListPtr() const noexcept | ||||
| { | { | ||||
| return CharStringListPtr(*this); | return CharStringListPtr(*this); | ||||
| @@ -210,8 +302,13 @@ public: | |||||
| { | { | ||||
| clear(); | clear(); | ||||
| CARLA_SAFE_ASSERT_RETURN(charStringList != nullptr, *this); | |||||
| for (int i=0; charStringList[i] != nullptr; ++i) | for (int i=0; charStringList[i] != nullptr; ++i) | ||||
| append(charStringList[i]); | |||||
| { | |||||
| if (const char* const string = carla_strdup_safe(charStringList[i])) | |||||
| LinkedList<const char*>::append(string); | |||||
| } | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| @@ -221,13 +318,15 @@ public: | |||||
| clear(); | clear(); | ||||
| for (Itenerator it = list.begin(); it.valid(); it.next()) | for (Itenerator it = list.begin(); it.valid(); it.next()) | ||||
| LinkedList<CarlaString>::append(it.getValue()); | |||||
| { | |||||
| if (const char* const string = carla_strdup_safe(it.getValue())) | |||||
| LinkedList<const char*>::append(string); | |||||
| } | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| private: | |||||
| LinkedList<CarlaString> fList; | |||||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||||
| }; | }; | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -37,11 +37,14 @@ protected: | |||||
| * Constructor. | * Constructor. | ||||
| */ | */ | ||||
| CarlaThread(const char* const threadName = nullptr) noexcept | 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. | * Destructor. | ||||
| @@ -20,8 +20,6 @@ | |||||
| #include "CarlaUtils.hpp" | #include "CarlaUtils.hpp" | ||||
| #include <new> | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // Define list_entry and list_entry_const | // Define list_entry and list_entry_const | ||||
| @@ -47,27 +45,11 @@ | |||||
| ((const type *)((const char *)(ptr)-offsetof(type, member))) | ((const type *)((const char *)(ptr)-offsetof(type, member))) | ||||
| #endif | #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 | // Abstract Linked List class | ||||
| // _allocate() and _deallocate are virtual calls provided by subclasses | // _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<typename T> | template<typename T> | ||||
| class AbstractLinkedList | class AbstractLinkedList | ||||
| @@ -83,12 +65,10 @@ protected: | |||||
| ListHead siblings; | ListHead siblings; | ||||
| }; | }; | ||||
| AbstractLinkedList(const bool isClass) noexcept | |||||
| : kIsClass(isClass), | |||||
| kDataSize(sizeof(Data)) | |||||
| { | |||||
| _init(); | |||||
| } | |||||
| AbstractLinkedList() noexcept | |||||
| : kDataSize(sizeof(Data)), | |||||
| fCount(0), | |||||
| fQueue({&fQueue, &fQueue}) {} | |||||
| public: | public: | ||||
| virtual ~AbstractLinkedList() noexcept | virtual ~AbstractLinkedList() noexcept | ||||
| @@ -158,8 +138,6 @@ public: | |||||
| Data* const data = list_entry(entry, Data, siblings); | Data* const data = list_entry(entry, Data, siblings); | ||||
| CARLA_SAFE_ASSERT_CONTINUE(data != nullptr); | CARLA_SAFE_ASSERT_CONTINUE(data != nullptr); | ||||
| if (kIsClass) | |||||
| data->~Data(); | |||||
| _deallocate(data); | _deallocate(data); | ||||
| } | } | ||||
| @@ -364,7 +342,6 @@ public: | |||||
| } | } | ||||
| protected: | protected: | ||||
| const bool kIsClass; | |||||
| const size_t kDataSize; | const size_t kDataSize; | ||||
| size_t fCount; | size_t fCount; | ||||
| @@ -383,11 +360,9 @@ private: | |||||
| void _createData(Data* const data, const T& value) noexcept | void _createData(Data* const data, const T& value) noexcept | ||||
| { | { | ||||
| if (kIsClass) | |||||
| new(data)Data(); | |||||
| data->value = value; | |||||
| ++fCount; | ++fCount; | ||||
| data->value = value; | |||||
| //std::memcpy(data->value, value, kDataSize); | |||||
| } | } | ||||
| bool _add(const T& value, const bool inTail, ListHead* const queue) noexcept | bool _add(const T& value, const bool inTail, ListHead* const queue) noexcept | ||||
| @@ -397,9 +372,9 @@ private: | |||||
| _createData(data, value); | _createData(data, value); | ||||
| if (inTail) | if (inTail) | ||||
| __list_add(&data->siblings, queue->prev, queue); | |||||
| __list_add(data->siblings, queue->prev, queue); | |||||
| else | else | ||||
| __list_add(&data->siblings, queue, queue->next); | |||||
| __list_add(data->siblings, queue, queue->next); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -413,11 +388,8 @@ private: | |||||
| entry->next = nullptr; | entry->next = nullptr; | ||||
| entry->prev = nullptr; | entry->prev = nullptr; | ||||
| --fCount; | |||||
| if (kIsClass) | |||||
| data->~Data(); | |||||
| _deallocate(data); | _deallocate(data); | ||||
| --fCount; | |||||
| } | } | ||||
| const T& _get(ListHead* const entry, const T& fallback) const noexcept | 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. | * 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; | ListHead* const at = head->next; | ||||
| first->prev = head; | first->prev = head; | ||||
| head->next = first; | |||||
| head->next = first; | |||||
| last->next = at; | last->next = at; | ||||
| at->prev = last; | |||||
| at->prev = last; | |||||
| } | } | ||||
| static void __list_splice_tail(ListHead* const list, ListHead* const head) noexcept | static void __list_splice_tail(ListHead* const list, ListHead* const head) noexcept | ||||
| @@ -492,7 +464,7 @@ private: | |||||
| ListHead* const at = head->prev; | ListHead* const at = head->prev; | ||||
| first->prev = at; | first->prev = at; | ||||
| at->next = first; | |||||
| at->next = first; | |||||
| last->next = head; | last->next = head; | ||||
| head->prev = last; | head->prev = last; | ||||
| @@ -500,7 +472,8 @@ private: | |||||
| template<typename> friend class RtLinkedList; | template<typename> friend class RtLinkedList; | ||||
| LINKED_LIST_DECLARATIONS(AbstractLinkedList) | |||||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_CLASS(AbstractLinkedList) | |||||
| }; | }; | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -510,8 +483,7 @@ template<typename T> | |||||
| class LinkedList : public AbstractLinkedList<T> | class LinkedList : public AbstractLinkedList<T> | ||||
| { | { | ||||
| public: | public: | ||||
| LinkedList(const bool isClass = false) noexcept | |||||
| : AbstractLinkedList<T>(isClass) {} | |||||
| LinkedList() noexcept {} | |||||
| protected: | protected: | ||||
| typename AbstractLinkedList<T>::Data* _allocate() noexcept override | typename AbstractLinkedList<T>::Data* _allocate() noexcept override | ||||
| @@ -526,7 +498,8 @@ protected: | |||||
| std::free(dataPtr); | std::free(dataPtr); | ||||
| } | } | ||||
| LINKED_LIST_DECLARATIONS(LinkedList) | |||||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_CLASS(LinkedList) | |||||
| }; | }; | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -93,14 +93,16 @@ public: | |||||
| private: | private: | ||||
| mutable RtMemPool_Handle fHandle; | mutable RtMemPool_Handle fHandle; | ||||
| const size_t kDataSize; | const size_t kDataSize; | ||||
| CARLA_PREVENT_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_CLASS(Pool) | |||||
| }; | }; | ||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| // Now the actual rt-linkedlist code | // Now the actual rt-linkedlist code | ||||
| RtLinkedList(Pool& memPool, const bool isClass = false) noexcept | |||||
| : AbstractLinkedList<T>(isClass), | |||||
| fMemPool(memPool) {} | |||||
| RtLinkedList(Pool& memPool) noexcept | |||||
| : fMemPool(memPool) {} | |||||
| bool append_sleepy(const T& value) noexcept | bool append_sleepy(const T& value) noexcept | ||||
| { | { | ||||
| @@ -161,9 +163,9 @@ private: | |||||
| this->_createData(data, value); | this->_createData(data, value); | ||||
| if (inTail) | if (inTail) | ||||
| this->__list_add(&data->siblings, this->fQueue.prev, &this->fQueue); | |||||
| this->__list_add(data->siblings, this->fQueue.prev, &(this->fQueue)); | |||||
| else | else | ||||
| this->__list_add(&data->siblings, &this->fQueue, this->fQueue.next); | |||||
| this->__list_add(data->siblings, &(this->fQueue), this->fQueue.next); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -171,7 +173,8 @@ private: | |||||
| return false; | return false; | ||||
| } | } | ||||
| LINKED_LIST_DECLARATIONS(RtLinkedList) | |||||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||||
| CARLA_DECLARE_NON_COPY_CLASS(RtLinkedList) | |||||
| }; | }; | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||