fix memory leak when waking from screensaver mode

This commit is contained in:
Joey Castillo 2021-10-05 15:55:34 -04:00
parent 83192b3a58
commit 8372e37bea
4 changed files with 11 additions and 3 deletions

View File

@ -56,6 +56,14 @@ void app_wake_from_deep_sleep() {
} }
void app_setup() { void app_setup() {
static bool is_first_launch = true;
if (is_first_launch) {
for(uint8_t i = 0; i < LAUNCHER_NUM_WIDGETS; i++) {
widget_contexts[i] = NULL;
is_first_launch = false;
}
}
if (launcher_state.screensaver_ticks != -1) { if (launcher_state.screensaver_ticks != -1) {
watch_disable_extwake_interrupt(BTN_ALARM); watch_disable_extwake_interrupt(BTN_ALARM);
watch_rtc_disable_alarm_callback(); watch_rtc_disable_alarm_callback();

View File

@ -5,7 +5,7 @@
void simple_clock_widget_setup(LauncherSettings *settings, void ** context_ptr) { void simple_clock_widget_setup(LauncherSettings *settings, void ** context_ptr) {
(void) settings; (void) settings;
// the only context we need is the timestamp of the previous tick. // the only context we need is the timestamp of the previous tick.
*context_ptr = malloc(sizeof(uint32_t)); if (*context_ptr == NULL) *context_ptr = malloc(sizeof(uint32_t));
} }
void simple_clock_widget_activate(LauncherSettings *settings, void *context) { void simple_clock_widget_activate(LauncherSettings *settings, void *context) {

View File

@ -7,7 +7,7 @@ const char preferences_widget_titles[PREFERENCES_WIDGET_NUM_PREFEFENCES][11] = {
void preferences_widget_setup(LauncherSettings *settings, void ** context_ptr) { void preferences_widget_setup(LauncherSettings *settings, void ** context_ptr) {
(void) settings; (void) settings;
*context_ptr = malloc(sizeof(uint8_t)); if (*context_ptr == NULL) *context_ptr = malloc(sizeof(uint8_t));
} }
void preferences_widget_activate(LauncherSettings *settings, void *context) { void preferences_widget_activate(LauncherSettings *settings, void *context) {

View File

@ -7,7 +7,7 @@ const char set_time_widget_titles[SET_TIME_WIDGET_NUM_SETTINGS][3] = {"HR", "MN"
void set_time_widget_setup(LauncherSettings *settings, void ** context_ptr) { void set_time_widget_setup(LauncherSettings *settings, void ** context_ptr) {
(void) settings; (void) settings;
*context_ptr = malloc(sizeof(uint8_t)); if (*context_ptr == NULL) *context_ptr = malloc(sizeof(uint8_t));
} }
void set_time_widget_activate(LauncherSettings *settings, void *context) { void set_time_widget_activate(LauncherSettings *settings, void *context) {