@@ -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) {} | ||||
@@ -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 | ||||
{ | { | ||||
@@ -123,10 +123,28 @@ uint RackGraph::MIDI::getPortId(const bool isInput, const char portName[], bool* | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// RackGraph | // RackGraph | ||||
RackGraph::Audio::Audio() noexcept | |||||
: mutex(), | |||||
connectedIn1(), | |||||
connectedIn2(), | |||||
connectedOut1(), | |||||
connectedOut2(), | |||||
inBuf{0, 0}, | |||||
inBufTmp{0, 0}, | |||||
outBuf{0, 0} {} | |||||
RackGraph::MIDI::MIDI() noexcept | |||||
: ins(), | |||||
outs() {} | |||||
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; | ||||
MIDI() noexcept; | |||||
// c++ compat stuff | |||||
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; | ||||
@@ -17,6 +17,8 @@ | |||||
#ifndef LILV_LILVMM_HPP | #ifndef LILV_LILVMM_HPP | ||||
#define LILV_LILVMM_HPP | #define LILV_LILVMM_HPP | ||||
#include "CarlaDefines.h" | |||||
#include "lilv/lilv.h" | #include "lilv/lilv.h" | ||||
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) | #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) | ||||
@@ -97,6 +99,12 @@ struct Node { | |||||
LILV_WRAP0_CONST(bool, node, is_bool); | LILV_WRAP0_CONST(bool, node, is_bool); | ||||
LILV_WRAP0_CONST(bool, node, as_bool); | LILV_WRAP0_CONST(bool, node, as_bool); | ||||
Node& operator=(const Node& copy) { | |||||
lilv_node_free(me); | |||||
me = lilv_node_duplicate(copy.me); | |||||
return *this; | |||||
} | |||||
LilvNode* me; | LilvNode* me; | ||||
}; | }; | ||||
@@ -108,6 +116,8 @@ struct ScalePoint { | |||||
LILV_WRAP0(const LilvNode*, scale_point, get_value); | LILV_WRAP0(const LilvNode*, scale_point, get_value); | ||||
const LilvScalePoint* me; | const LilvScalePoint* me; | ||||
//CARLA_DECLARE_NON_COPY_STRUCT(ScalePoint) | |||||
}; | }; | ||||
struct PluginClass { | struct PluginClass { | ||||
@@ -120,6 +130,8 @@ struct PluginClass { | |||||
LILV_WRAP0(LilvPluginClasses*, plugin_class, get_children); | LILV_WRAP0(LilvPluginClasses*, plugin_class, get_children); | ||||
const LilvPluginClass* me; | const LilvPluginClass* me; | ||||
//CARLA_DECLARE_NON_COPY_STRUCT(PluginClass) | |||||
}; | }; | ||||
#define LILV_WRAP_COLL(CT, ET, prefix) \ | #define LILV_WRAP_COLL(CT, ET, prefix) \ | ||||
@@ -165,6 +177,8 @@ struct UI { | |||||
LILV_WRAP0(Nodes, ui, get_extension_data); | LILV_WRAP0(Nodes, ui, get_extension_data); | ||||
const LilvUI* me; | const LilvUI* me; | ||||
//CARLA_DECLARE_NON_COPY_STRUCT(UI) | |||||
}; | }; | ||||
struct UIs { | struct UIs { | ||||
@@ -198,6 +212,8 @@ struct Port { | |||||
const LilvPlugin* parent; | const LilvPlugin* parent; | ||||
const LilvPort* me; | const LilvPort* me; | ||||
//CARLA_DECLARE_NON_COPY_STRUCT(Port) | |||||
}; | }; | ||||
struct Plugin { | struct Plugin { | ||||
@@ -254,6 +270,8 @@ struct Plugin { | |||||
} | } | ||||
const LilvPlugin* me; | const LilvPlugin* me; | ||||
//CARLA_DECLARE_NON_COPY_STRUCT(Plugin) | |||||
}; | }; | ||||
struct Plugins { | struct Plugins { | ||||
@@ -265,15 +283,13 @@ struct Instance { | |||||
inline Instance(LilvInstance* instance) : me(instance) {} | inline Instance(LilvInstance* instance) : me(instance) {} | ||||
LILV_DEPRECATED | LILV_DEPRECATED | ||||
inline Instance(Plugin plugin, double sample_rate) { | |||||
me = lilv_plugin_instantiate(plugin, sample_rate, nullptr); | |||||
} | |||||
inline Instance(Plugin plugin, double sample_rate) | |||||
: me(lilv_plugin_instantiate(plugin, sample_rate, nullptr)) {} | |||||
LILV_DEPRECATED inline Instance(Plugin plugin, | LILV_DEPRECATED inline Instance(Plugin plugin, | ||||
double sample_rate, | double sample_rate, | ||||
LV2_Feature* const* features) { | |||||
me = lilv_plugin_instantiate(plugin, sample_rate, features); | |||||
} | |||||
LV2_Feature* const* features) | |||||
me(lilv_plugin_instantiate(plugin, sample_rate, features)) {} | |||||
static inline Instance* create(Plugin plugin, | static inline Instance* create(Plugin plugin, | ||||
double sample_rate, | double sample_rate, | ||||
@@ -307,11 +323,13 @@ struct Instance { | |||||
} | } | ||||
LilvInstance* me; | LilvInstance* me; | ||||
//CARLA_DECLARE_NON_COPY_STRUCT(Instance) | |||||
}; | }; | ||||
struct World { | struct World { | ||||
inline World() : me(lilv_world_new()) {} | |||||
inline ~World() { lilv_world_free(me); } | |||||
inline World() : me(lilv_world_new()) {} | |||||
inline virtual ~World() { lilv_world_free(me); } | |||||
inline LilvNode* new_uri(const char* uri) const { | inline LilvNode* new_uri(const char* uri) const { | ||||
return lilv_new_uri(me, uri); | return lilv_new_uri(me, uri); | ||||
@@ -343,6 +361,8 @@ struct World { | |||||
LILV_WRAP1(int, world, load_resource, const LilvNode*, resource); | LILV_WRAP1(int, world, load_resource, const LilvNode*, resource); | ||||
LilvWorld* me; | LilvWorld* me; | ||||
CARLA_DECLARE_NON_COPY_STRUCT(World) | |||||
}; | }; | ||||
} /* namespace Lilv */ | } /* namespace Lilv */ | ||||
@@ -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,7 +30,7 @@ | |||||
class LeakTestClass | class LeakTestClass | ||||
{ | { | ||||
public: | public: | ||||
LeakTestClass()noexcept | |||||
LeakTestClass() noexcept | |||||
: i(0) {} | : i(0) {} | ||||
private: | private: | ||||
@@ -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() | ||||
@@ -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 | ||||
{ | { | ||||
@@ -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) | |||||
}; | }; | ||||
// ----------------------------------------------------- | // ----------------------------------------------------- | ||||
@@ -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 | ||||
{ | { | ||||
@@ -163,14 +163,12 @@ public: | |||||
CarlaStringList() noexcept | CarlaStringList() noexcept | ||||
: LinkedList<CarlaString>(true) {} | : LinkedList<CarlaString>(true) {} | ||||
#if 0 | |||||
CarlaStringList(const CarlaStringList& list) noexcept | CarlaStringList(const CarlaStringList& list) noexcept | ||||
: LinkedList<CarlaString>(true) | : LinkedList<CarlaString>(true) | ||||
{ | { | ||||
for (Itenerator it = list.begin(); it.valid(); it.next()) | for (Itenerator it = list.begin(); it.valid(); it.next()) | ||||
LinkedList<CarlaString>::append(it.getValue()); | LinkedList<CarlaString>::append(it.getValue()); | ||||
} | } | ||||
#endif | |||||
~CarlaStringList() noexcept | ~CarlaStringList() noexcept | ||||
{ | { | ||||
@@ -226,8 +224,7 @@ public: | |||||
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. | ||||
@@ -47,22 +47,6 @@ | |||||
((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 | ||||
@@ -85,10 +69,9 @@ protected: | |||||
AbstractLinkedList(const bool isClass) noexcept | AbstractLinkedList(const bool isClass) noexcept | ||||
: kIsClass(isClass), | : kIsClass(isClass), | ||||
kDataSize(sizeof(Data)) | |||||
{ | |||||
_init(); | |||||
} | |||||
kDataSize(sizeof(Data)), | |||||
fCount(0), | |||||
fQueue({&fQueue, &fQueue}) {} | |||||
public: | public: | ||||
virtual ~AbstractLinkedList() noexcept | virtual ~AbstractLinkedList() noexcept | ||||
@@ -384,9 +367,10 @@ private: | |||||
void _createData(Data* const data, const T& value) noexcept | void _createData(Data* const data, const T& value) noexcept | ||||
{ | { | ||||
if (kIsClass) | if (kIsClass) | ||||
new(data)Data(); | |||||
new(data)Data({value, {nullptr, nullptr}}); | |||||
else | |||||
data->value = value; | |||||
data->value = value; | |||||
++fCount; | ++fCount; | ||||
} | } | ||||
@@ -397,9 +381,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; | ||||
} | } | ||||
@@ -454,12 +438,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& new_, ListHead* const prev, ListHead* const next) noexcept | |||||
{ | { | ||||
next->prev = new_; | |||||
new_->next = next; | |||||
new_->prev = prev; | |||||
prev->next = new_; | |||||
next->prev = &new_; | |||||
new_.next = next; | |||||
new_.prev = prev; | |||||
prev->next = &new_; | |||||
} | } | ||||
/* | /* | ||||
@@ -500,7 +484,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) | |||||
}; | }; | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -526,7 +511,8 @@ protected: | |||||
std::free(dataPtr); | std::free(dataPtr); | ||||
} | } | ||||
LINKED_LIST_DECLARATIONS(LinkedList) | |||||
CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||||
CARLA_DECLARE_NON_COPY_CLASS(LinkedList) | |||||
}; | }; | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -93,6 +93,9 @@ 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) | |||||
}; | }; | ||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
@@ -161,9 +164,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 +174,8 @@ private: | |||||
return false; | return false; | ||||
} | } | ||||
LINKED_LIST_DECLARATIONS(RtLinkedList) | |||||
CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||||
CARLA_DECLARE_NON_COPY_CLASS(RtLinkedList) | |||||
}; | }; | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||