Skip to content

Commit

Permalink
Use std::nothrow for memory allocation to avoid unhandled exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueAndi committed Dec 18, 2023
1 parent be56295 commit 9d8ab2a
Show file tree
Hide file tree
Showing 27 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/BTCQuotePlugin/src/BTCQuotePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class BTCQuotePlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new BTCQuotePlugin(name, uid);
return new(std::nothrow) BTCQuotePlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/BatteryPlugin/src/BatteryPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class BatteryPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new BatteryPlugin(name, uid);
return new(std::nothrow) BatteryPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/CountdownPlugin/src/CountdownPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class CountdownPlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new CountdownPlugin(name, uid);
return new(std::nothrow) CountdownPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/DDPPlugin/src/DDPPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class DDPPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new DDPPlugin(name, uid);
return new(std::nothrow) DDPPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/DateTimePlugin/src/DateTimePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class DateTimePlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new DateTimePlugin(name, uid);
return new(std::nothrow) DateTimePlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/GameOfLifePlugin/src/GameOfLifePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class GameOfLifePlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new GameOfLifePlugin(name, uid);
return new(std::nothrow)GameOfLifePlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/GrabViaMqttPlugin/src/GrabViaMqttPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class GrabViaMqttPlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new GrabViaMqttPlugin(name, uid);
return new(std::nothrow)GrabViaMqttPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/GrabViaRestPlugin/src/GrabViaRestPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class GrabViaRestPlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new GrabViaRestPlugin(name, uid);
return new(std::nothrow)GrabViaRestPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/GruenbeckPlugin/src/GruenbeckPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class GruenbeckPlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new GruenbeckPlugin(name, uid);
return new(std::nothrow)GruenbeckPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/IconTextLampPlugin/src/IconTextLampPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class IconTextLampPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new IconTextLampPlugin(name, uid);
return new(std::nothrow)IconTextLampPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/IconTextPlugin/src/IconTextPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class IconTextPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new IconTextPlugin(name, uid);
return new(std::nothrow)IconTextPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/JustTextPlugin/src/JustTextPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class JustTextPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new JustTextPlugin(name, uid);
return new(std::nothrow)JustTextPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/MatrixPlugin/src/MatrixPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class MatrixPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new MatrixPlugin(name, uid);
return new(std::nothrow)MatrixPlugin(name, uid);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/OpenWeatherPlugin/src/OpenWeatherPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,15 @@ void OpenWeatherPlugin::createOpenWeatherSource(OpenWeatherSource id)
switch(id)
{
case OPENWEATHER_SOURCE_CURRENT:
m_source = new (std::nothrow) OpenWeatherCurrent();
m_source = new(std::nothrow) OpenWeatherCurrent();
break;

case OPENWEATHER_SOURCE_ONE_CALL_25:
m_source = new (std::nothrow) OpenWeatherOneCall("2.5");
m_source = new(std::nothrow) OpenWeatherOneCall("2.5");
break;

case OPENWEATHER_SOURCE_ONE_CALL_30:
m_source = new (std::nothrow) OpenWeatherOneCall("3.0");
m_source = new(std::nothrow) OpenWeatherOneCall("3.0");
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion lib/OpenWeatherPlugin/src/OpenWeatherPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class OpenWeatherPlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new OpenWeatherPlugin(name, uid);
return new(std::nothrow)OpenWeatherPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/RainbowPlugin/src/RainbowPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class RainbowPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new RainbowPlugin(name, uid);
return new(std::nothrow)RainbowPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/SensorPlugin/src/SensorPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class SensorPlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new SensorPlugin(name, uid);
return new(std::nothrow)SensorPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/SignalDetectorPlugin/src/SignalDetectorPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SignalDetectorPlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new SignalDetectorPlugin(name, uid);
return new(std::nothrow)SignalDetectorPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/SoundReactivePlugin/src/SoundReactivePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class SoundReactivePlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new SoundReactivePlugin(name, uid);
return new(std::nothrow)SoundReactivePlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/SunrisePlugin/src/SunrisePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class SunrisePlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new SunrisePlugin(name, uid);
return new(std::nothrow)SunrisePlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/SysMsgPlugin/src/SysMsgPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class SysMsgPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new SysMsgPlugin(name, uid);
return new(std::nothrow)SysMsgPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/TempHumidPlugin/src/TempHumidPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class TempHumidPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new TempHumidPlugin(name, uid);
return new(std::nothrow)TempHumidPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/TestPlugin/src/TestPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class TestPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new TestPlugin(name, uid);
return new(std::nothrow)TestPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/ThreeIconPlugin/src/ThreeIconPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ThreeIconPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new ThreeIconPlugin(name, uid);
return new(std::nothrow)ThreeIconPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/VolumioPlugin/src/VolumioPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class VolumioPlugin : public Plugin, private PluginConfigFsHandler
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new VolumioPlugin(name, uid);
return new(std::nothrow)VolumioPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/WifiStatusPlugin/src/WifiStatusPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class WifiStatusPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new WifiStatusPlugin(name, uid);
return new(std::nothrow)WifiStatusPlugin(name, uid);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/WormPlugin/src/WormPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class WormPlugin : public Plugin
*/
static IPluginMaintenance* create(const String& name, uint16_t uid)
{
return new WormPlugin(name, uid);
return new(std::nothrow)WormPlugin(name, uid);
}

/**
Expand Down

0 comments on commit 9d8ab2a

Please sign in to comment.