mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-27 10:41:15 -06:00
Firmware updater: Fix a race condition
avrdude: Handle OOM with configurable handler
This commit is contained in:
parent
bd667aad6e
commit
60a0375ff9
14 changed files with 193 additions and 67 deletions
|
|
@ -144,6 +144,33 @@ void avrdude_progress_external(const char *task, unsigned progress)
|
|||
avrdude_progress_handler(task, progress, avrdude_progress_handler_user_p);
|
||||
}
|
||||
|
||||
static void avrdude_oom_handler_null(const char *context, void *user_p)
|
||||
{
|
||||
// Output a message and just exit
|
||||
fputs("avrdude: Out of memory: ", stderr);
|
||||
fputs(context, stderr);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
static void *avrdude_oom_handler_user_p = NULL;
|
||||
static avrdude_oom_handler_t avrdude_oom_handler = avrdude_oom_handler_null;
|
||||
|
||||
void avrdude_oom_handler_set(avrdude_oom_handler_t newhandler, void *user_p)
|
||||
{
|
||||
if (newhandler != NULL) {
|
||||
avrdude_oom_handler = newhandler;
|
||||
avrdude_oom_handler_user_p = user_p;
|
||||
} else {
|
||||
avrdude_oom_handler = avrdude_oom_handler_null;
|
||||
avrdude_oom_handler_user_p = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void avrdude_oom(const char *context)
|
||||
{
|
||||
avrdude_oom_handler(context, avrdude_oom_handler_user_p);
|
||||
}
|
||||
|
||||
void avrdude_cancel()
|
||||
{
|
||||
cancel_flag = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue