mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-16 00:43:00 +03:00
remove (std::nothrow) where nullptr case is not handled
remove legacy new management
This commit is contained in:
@ -7,7 +7,7 @@ typedef void (*voidFuncPtr)(void);
|
||||
typedef void (*voidFuncPtrArg)(void*);
|
||||
|
||||
// Helper functions for Functional interrupt routines
|
||||
extern "C" bool __attachInterruptFunctionalArg(uint8_t pin, voidFuncPtr userFunc, void*fp, int mode, bool functional);
|
||||
extern "C" void __attachInterruptFunctionalArg(uint8_t pin, voidFuncPtr userFunc, void*fp, int mode, bool functional);
|
||||
|
||||
|
||||
void ICACHE_RAM_ATTR interruptFunctional(void* arg)
|
||||
@ -34,52 +34,32 @@ extern "C"
|
||||
}
|
||||
}
|
||||
|
||||
bool attachInterrupt(uint8_t pin, std::function<void(void)> intRoutine, int mode)
|
||||
void attachInterrupt(uint8_t pin, std::function<void(void)> intRoutine, int mode)
|
||||
{
|
||||
// use the local interrupt routine which takes the ArgStructure as argument
|
||||
|
||||
InterruptInfo* ii = nullptr;
|
||||
|
||||
FunctionInfo* fi = new (std::nothrow) FunctionInfo;
|
||||
if (fi == nullptr)
|
||||
return false;
|
||||
FunctionInfo* fi = new FunctionInfo;
|
||||
fi->reqFunction = intRoutine;
|
||||
|
||||
ArgStructure* as = new (std::nothrow) ArgStructure;
|
||||
if (as == nullptr)
|
||||
{
|
||||
delete(fi);
|
||||
return false;
|
||||
}
|
||||
ArgStructure* as = new ArgStructure;
|
||||
as->interruptInfo = ii;
|
||||
as->functionInfo = fi;
|
||||
|
||||
return __attachInterruptFunctionalArg(pin, (voidFuncPtr)interruptFunctional, as, mode, true);
|
||||
__attachInterruptFunctionalArg(pin, (voidFuncPtr)interruptFunctional, as, mode, true);
|
||||
}
|
||||
|
||||
bool attachScheduledInterrupt(uint8_t pin, std::function<void(InterruptInfo)> scheduledIntRoutine, int mode)
|
||||
void attachScheduledInterrupt(uint8_t pin, std::function<void(InterruptInfo)> scheduledIntRoutine, int mode)
|
||||
{
|
||||
InterruptInfo* ii = new (std::nothrow) InterruptInfo;
|
||||
if (ii == nullptr)
|
||||
return false;
|
||||
InterruptInfo* ii = new InterruptInfo;
|
||||
|
||||
FunctionInfo* fi = new FunctionInfo;
|
||||
if (fi == nullptr)
|
||||
{
|
||||
delete ii;
|
||||
return false;
|
||||
}
|
||||
fi->reqScheduledFunction = scheduledIntRoutine;
|
||||
|
||||
ArgStructure* as = new (std::nothrow) ArgStructure;
|
||||
if (as == nullptr)
|
||||
{
|
||||
delete ii;
|
||||
delete fi;
|
||||
return false;
|
||||
}
|
||||
ArgStructure* as = new ArgStructure;
|
||||
as->interruptInfo = ii;
|
||||
as->functionInfo = fi;
|
||||
|
||||
return __attachInterruptFunctionalArg(pin, (voidFuncPtr)interruptFunctional, as, mode, true);
|
||||
__attachInterruptFunctionalArg(pin, (voidFuncPtr)interruptFunctional, as, mode, true);
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ struct ArgStructure {
|
||||
FunctionInfo* functionInfo = nullptr;
|
||||
};
|
||||
|
||||
bool attachInterrupt(uint8_t pin, std::function<void(void)> intRoutine, int mode);
|
||||
bool attachScheduledInterrupt(uint8_t pin, std::function<void(InterruptInfo)> scheduledIntRoutine, int mode);
|
||||
void attachInterrupt(uint8_t pin, std::function<void(void)> intRoutine, int mode);
|
||||
void attachScheduledInterrupt(uint8_t pin, std::function<void(InterruptInfo)> scheduledIntRoutine, int mode);
|
||||
|
||||
|
||||
#endif //INTERRUPTS_H
|
||||
|
@ -182,7 +182,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
|
||||
} else {
|
||||
_bufferSize = 256;
|
||||
}
|
||||
_buffer = new (std::nothrow) uint8_t[_bufferSize];
|
||||
_buffer = new uint8_t[_bufferSize];
|
||||
_command = command;
|
||||
|
||||
#ifdef DEBUG_UPDATER
|
||||
|
Reference in New Issue
Block a user