comparison plugin/NativeVampPluginFactory.cpp @ 1582:70e172e6cc59 fix-static-analysis

Use nullptr throughout
author Chris Cannam
date Mon, 26 Nov 2018 14:33:41 +0000
parents 232d6ddf257d
children 5750b9e60818
comparison
equal deleted inserted replaced
1581:ad5f892c0c4d 1582:70e172e6cc59
52 PluginDeletionNotifyAdapter::~PluginDeletionNotifyAdapter() 52 PluginDeletionNotifyAdapter::~PluginDeletionNotifyAdapter()
53 { 53 {
54 // see notes in vamp-sdk/hostext/PluginLoader.cpp from which this is drawn 54 // see notes in vamp-sdk/hostext/PluginLoader.cpp from which this is drawn
55 Vamp::Plugin *p = m_plugin; 55 Vamp::Plugin *p = m_plugin;
56 delete m_plugin; 56 delete m_plugin;
57 m_plugin = 0; 57 m_plugin = nullptr;
58 // acceptable use after free here, as pluginDeleted uses p only as 58 // acceptable use after free here, as pluginDeleted uses p only as
59 // pointer key and does not deref it 59 // pointer key and does not deref it
60 if (m_factory) m_factory->pluginDeleted(p); 60 if (m_factory) m_factory->pluginDeleted(p);
61 } 61 }
62 62
145 145
146 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 146 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
147 cerr << "NativeVampPluginFactory::getPluginIdentifiers: Vamp descriptor found" << endl; 147 cerr << "NativeVampPluginFactory::getPluginIdentifiers: Vamp descriptor found" << endl;
148 #endif 148 #endif
149 149
150 const VampPluginDescriptor *descriptor = 0; 150 const VampPluginDescriptor *descriptor = nullptr;
151 int index = 0; 151 int index = 0;
152 152
153 map<string, int> known; 153 map<string, int> known;
154 bool ok = true; 154 bool ok = true;
155 155
291 NativeVampPluginFactory::instantiatePlugin(QString identifier, 291 NativeVampPluginFactory::instantiatePlugin(QString identifier,
292 sv_samplerate_t inputSampleRate) 292 sv_samplerate_t inputSampleRate)
293 { 293 {
294 Profiler profiler("NativeVampPluginFactory::instantiatePlugin"); 294 Profiler profiler("NativeVampPluginFactory::instantiatePlugin");
295 295
296 Vamp::Plugin *rv = 0; 296 Vamp::Plugin *rv = nullptr;
297 Vamp::PluginHostAdapter *plugin = 0; 297 Vamp::PluginHostAdapter *plugin = nullptr;
298 298
299 const VampPluginDescriptor *descriptor = 0; 299 const VampPluginDescriptor *descriptor = nullptr;
300 int index = 0; 300 int index = 0;
301 301
302 QString type, soname, label; 302 QString type, soname, label;
303 PluginIdentifier::parseIdentifier(identifier, type, soname, label); 303 PluginIdentifier::parseIdentifier(identifier, type, soname, label);
304 if (type != "vamp") { 304 if (type != "vamp") {
305 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 305 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
306 cerr << "NativeVampPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type << endl; 306 cerr << "NativeVampPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type << endl;
307 #endif 307 #endif
308 return 0; 308 return nullptr;
309 } 309 }
310 310
311 QString found = findPluginFile(soname); 311 QString found = findPluginFile(soname);
312 312
313 if (found == "") { 313 if (found == "") {
314 SVDEBUG << "NativeVampPluginFactory::instantiatePlugin: Failed to find library file " << soname << endl; 314 SVDEBUG << "NativeVampPluginFactory::instantiatePlugin: Failed to find library file " << soname << endl;
315 return 0; 315 return nullptr;
316 } else if (found != soname) { 316 } else if (found != soname) {
317 317
318 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 318 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
319 cerr << "NativeVampPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl; 319 cerr << "NativeVampPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl;
320 cerr << soname << " -> " << found << endl; 320 cerr << soname << " -> " << found << endl;
326 326
327 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); 327 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL);
328 328
329 if (!libraryHandle) { 329 if (!libraryHandle) {
330 SVDEBUG << "NativeVampPluginFactory::instantiatePlugin: Failed to load library " << soname << ": " << DLERROR() << endl; 330 SVDEBUG << "NativeVampPluginFactory::instantiatePlugin: Failed to load library " << soname << ": " << DLERROR() << endl;
331 return 0; 331 return nullptr;
332 } 332 }
333 333
334 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) 334 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
335 DLSYM(libraryHandle, "vampGetPluginDescriptor"); 335 DLSYM(libraryHandle, "vampGetPluginDescriptor");
336 336