Browse Source

Add carla_zeroPointers function, use it instead of _fill<void*>

tags/1.9.6
falkTX 9 years ago
parent
commit
a37ff5ceff
5 changed files with 19 additions and 6 deletions
  1. +3
    -3
      source/backend/engine/CarlaEngineJack.cpp
  2. +1
    -1
      source/backend/plugin/CarlaPluginLV2.cpp
  3. +1
    -1
      source/backend/plugin/CarlaPluginVST2.cpp
  4. +1
    -1
      source/bridges-ui/CarlaBridgeUI-LV2.cpp
  5. +13
    -0
      source/utils/CarlaUtils.hpp

+ 3
- 3
source/backend/engine/CarlaEngineJack.cpp View File

@@ -667,7 +667,7 @@ public:
#ifdef BUILD_BRIDGE
pData->options.processMode = ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS;
#else
carla_fill<jack_port_t*>(fRackPorts, nullptr, kRackPortCount);
carla_zeroPointers(fRackPorts, kRackPortCount);
#endif

// FIXME: Always enable JACK transport for now
@@ -877,7 +877,7 @@ public:
jackbridge_port_unregister(fClient, fRackPorts[kRackPortEventIn]);
jackbridge_port_unregister(fClient, fRackPorts[kRackPortEventOut]);
}
carla_fill<jack_port_t*>(fRackPorts, nullptr, kRackPortCount);
carla_zeroPointers(fRackPorts, kRackPortCount);

pData->graph.destroy();
}
@@ -1711,7 +1711,7 @@ protected:

fClient = nullptr;
#ifndef BUILD_BRIDGE
carla_fill<jack_port_t*>(fRackPorts, nullptr, kRackPortCount);
carla_zeroPointers(fRackPorts, kRackPortCount);
#endif
runPendingRtEvents();



+ 1
- 1
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -517,7 +517,7 @@ public:
{
carla_debug("CarlaPluginLV2::CarlaPluginLV2(%p, %i)", engine, id);

carla_fill<LV2_Feature*>(fFeatures, nullptr, kFeatureCountAll+1);
carla_zeroPointers(fFeatures, kFeatureCountAll+1);

for (uint32_t i=0; i < CARLA_URI_MAP_ID_COUNT; ++i)
fCustomURIDs.append(nullptr);


+ 1
- 1
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -2234,7 +2234,7 @@ private:
: numEvents(0),
reserved(0)
{
carla_fill<VstEvent*>(data, nullptr, kPluginMaxMidiEvents*2);
carla_zeroPointers(data, kPluginMaxMidiEvents*2);
}

CARLA_DECLARE_NON_COPY_STRUCT(FixedVstEvents);


+ 1
- 1
source/bridges-ui/CarlaBridgeUI-LV2.cpp View File

@@ -215,7 +215,7 @@ public:
fExt(),
leakDetector_CarlaLv2Client()
{
carla_fill<LV2_Feature*>(fFeatures, nullptr, kFeatureCount+1);
carla_zeroPointers(fFeatures, kFeatureCount+1);

for (uint32_t i=0; i < CARLA_URI_MAP_ID_COUNT; ++i)
fCustomURIDs.append(nullptr);


+ 13
- 0
source/utils/CarlaUtils.hpp View File

@@ -397,6 +397,19 @@ void carla_zeroChar(char* const data, const std::size_t numChars) noexcept
std::memset(data, 0, numChars*sizeof(char));
}

/*
* Clear a pointer array.
*/
template<typename T>
static inline
void carla_zeroPointers(T* pointers[], const std::size_t numPointers) noexcept
{
CARLA_SAFE_ASSERT_RETURN(pointers != nullptr,);
CARLA_SAFE_ASSERT_RETURN(numPointers > 0,);

std::memset(pointers, 0, numPointers*sizeof(T*));
}

/*
* Clear a single struct/class.
*/


Loading…
Cancel
Save