diff --git a/source/backend/plugin/Lv2Plugin.cpp b/source/backend/plugin/Lv2Plugin.cpp index 890f1500a..1a2ba882a 100644 --- a/source/backend/plugin/Lv2Plugin.cpp +++ b/source/backend/plugin/Lv2Plugin.cpp @@ -192,10 +192,12 @@ struct Lv2EventData { if (midi != nullptr) { if (midi->data != nullptr) + { delete[] midi->data; - delete midi; + midi->data = nullptr; + } - midi->data = nullptr; + delete midi; midi = nullptr; } } diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index 66de46687..61a68cc5b 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -2113,8 +2113,10 @@ public: lo_server_thread_start(fServerThread); } +#ifndef BUILD_ANSI_TEST lo_send_from(addr, lo_server_thread_get_server(fServerThread), LO_TT_IMMEDIATE, "/nsm/server/announce", "sssiii", "Carla", ":switch:", appName, NSM_API_VERSION_MAJOR, NSM_API_VERSION_MINOR, pid); +#endif lo_address_free(addr); } @@ -2184,8 +2186,10 @@ protected: for (int i=0; i < 30 && ! fIsOpened; i++) carla_msleep(100); +#ifndef BUILD_ANSI_TEST if (fIsOpened) lo_send_from(fReplyAddr, lo_server_thread_get_server(fServerThread), LO_TT_IMMEDIATE, "/reply", "ss", "/nsm/client/open", "OK"); +#endif return 0; @@ -2214,8 +2218,10 @@ protected: for (int i=0; i < 30 && ! fIsSaved; i++) carla_msleep(100); +#ifndef BUILD_ANSI_TEST if (fIsSaved) lo_send_from(fReplyAddr, lo_server_thread_get_server(fServerThread), LO_TT_IMMEDIATE, "/reply", "ss", "/nsm/client/save", "OK"); +#endif return 0; diff --git a/source/tests/ANSI.cpp b/source/tests/ANSI.cpp index a868c810a..c909913d5 100644 --- a/source/tests/ANSI.cpp +++ b/source/tests/ANSI.cpp @@ -20,7 +20,7 @@ // #include "CarlaPlugin.hpp" // #include "CarlaNative.h" // #include "CarlaNative.hpp" -#include "standalone/CarlaStandalone.cpp" +//#include "standalone/CarlaStandalone.cpp" // #include "CarlaMutex.hpp" // #include "CarlaString.hpp" diff --git a/source/tests/Makefile b/source/tests/Makefile index f7222a696..4c34bb8c9 100644 --- a/source/tests/Makefile +++ b/source/tests/Makefile @@ -18,7 +18,7 @@ BUILD_CXX_FLAGS += -isystem /usr/include/qt4 ANSI_CXX_FLAGS = -ansi -pedantic -pedantic-errors -Wunused-parameter -Wuninitialized -Wno-vla ANSI_CXX_FLAGS += -Wcast-qual -Wconversion -Wsign-conversion -Wlogical-op -Waggregate-return ANSI_CXX_FLAGS += -std=c++11 -Wzero-as-null-pointer-constant -ANSI_CXX_FLAGS += -DVESTIGE_HEADER -fPIC +ANSI_CXX_FLAGS += -DBUILD_ANSI_TEST -DVESTIGE_HEADER -fPIC TARGETS = ANSI CarlaString RtList Print Utils @@ -32,8 +32,8 @@ ANSI: ANSI.cpp CarlaString: CarlaString.cpp $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ -RtList: RtList.cpp ../libs/rtmempool.a - $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -pthread -lpthread -o $@ +RtList: RtList.cpp ../libs/rtmempool.a ../utils/RtList.hpp + $(CXX) RtList.cpp ../libs/rtmempool.a $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -pthread -lpthread -o $@ Print: Print.cpp $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ diff --git a/source/tests/RtList.cpp b/source/tests/RtList.cpp index e3ab65244..272e872ed 100644 --- a/source/tests/RtList.cpp +++ b/source/tests/RtList.cpp @@ -175,5 +175,32 @@ int main() assert(postRtEvents.dataPendingRT.count() == 0); assert(postRtEvents.dataPendingRT.isEmpty()); + // test non-rt + const unsigned int CARLA_EVENT_DATA_ATOM = 0x01; + const unsigned int CARLA_EVENT_DATA_MIDI_LL = 0x04; + + NonRtList evIns, evOuts; + evIns.append(CARLA_EVENT_DATA_ATOM); + evOuts.append(CARLA_EVENT_DATA_ATOM); + evOuts.append(CARLA_EVENT_DATA_MIDI_LL); + + if (evIns.count() > 0) + { + const size_t count(evIns.count()); + + for (uint32_t j=0; j < count; ++j) + { + const uint32_t& type(evIns.getAt(j)); + + if (type == CARLA_EVENT_DATA_ATOM) + pass(); + else if (type == CARLA_EVENT_DATA_MIDI_LL) + pass(); + } + } + + evIns.clear(); + evOuts.clear(); + return 0; } diff --git a/source/utils/RtList.hpp b/source/utils/RtList.hpp index fe2385270..25c31113f 100644 --- a/source/utils/RtList.hpp +++ b/source/utils/RtList.hpp @@ -52,21 +52,23 @@ protected: Itenerator(k_list_head* queue) : kQueue(queue), fEntry(queue->next), + fEntry2(fEntry->next), fData(nullptr) { CARLA_ASSERT(kQueue != nullptr); CARLA_ASSERT(fEntry != nullptr); + CARLA_ASSERT(fEntry2 != nullptr); } bool valid() { - prefetch(fEntry->next); return (fEntry != kQueue); } void next() { - fEntry = fEntry->next; + fEntry = fEntry2; + fEntry2 = fEntry->next; } T& operator*() @@ -79,6 +81,7 @@ protected: private: k_list_head* const kQueue; k_list_head* fEntry; + k_list_head* fEntry2; Data* fData; friend class List; @@ -107,8 +110,9 @@ public: if (fCount != 0) { k_list_head* entry; + k_list_head* entry2; - list_for_each(entry, &fQueue) + list_for_each_safe(entry, entry2, &fQueue) { if (Data* data = list_entry(entry, Data, siblings)) _deallocate(data); @@ -188,8 +192,9 @@ public: size_t i = 0; Data* data = nullptr; k_list_head* entry; + k_list_head* entry2; - list_for_each(entry, &fQueue) + list_for_each_safe(entry, entry2, &fQueue) { if (index != i++) continue; @@ -240,8 +245,9 @@ public: { Data* data = nullptr; k_list_head* entry; + k_list_head* entry2; - list_for_each(entry, &fQueue) + list_for_each_safe(entry, entry2, &fQueue) { data = list_entry(entry, Data, siblings); @@ -412,6 +418,8 @@ public: void resize(const size_t minPreallocated, const size_t maxPreallocated) { + CARLA_ASSERT(this->fCount == 0); + if (fHandle != nullptr) { rtsafe_memory_pool_destroy(fHandle); @@ -530,6 +538,7 @@ private: void _deallocate(typename List::Data* const dataPtr) override { + CARLA_ASSERT(dataPtr != nullptr); std::free(dataPtr); } @@ -559,6 +568,7 @@ private: void _deallocate(typename List::Data* const dataPtr) override { + CARLA_ASSERT(dataPtr != nullptr); delete dataPtr; }