Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FL-3309] Services: remove deallocator for persistent services #2692

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 2 additions & 53 deletions applications/services/desktop/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,58 +313,6 @@ Desktop* desktop_alloc() {
return desktop;
}

void desktop_free(Desktop* desktop) {
furi_assert(desktop);
furi_check(furi_record_destroy(RECORD_DESKTOP));

furi_pubsub_unsubscribe(
loader_get_pubsub(desktop->loader), desktop->app_start_stop_subscription);

if(desktop->input_events_subscription) {
furi_pubsub_unsubscribe(desktop->input_events_pubsub, desktop->input_events_subscription);
desktop->input_events_subscription = NULL;
}

desktop->loader = NULL;
desktop->input_events_pubsub = NULL;
furi_record_close(RECORD_LOADER);
furi_record_close(RECORD_NOTIFICATION);
furi_record_close(RECORD_INPUT_EVENTS);

view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdMain);
view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdLockMenu);
view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdLocked);
view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdDebug);
view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdHwMismatch);
view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdPinInput);
view_dispatcher_remove_view(desktop->view_dispatcher, DesktopViewIdPinTimeout);

view_dispatcher_free(desktop->view_dispatcher);
scene_manager_free(desktop->scene_manager);

animation_manager_free(desktop->animation_manager);
view_stack_free(desktop->main_view_stack);
desktop_main_free(desktop->main_view);
view_stack_free(desktop->locked_view_stack);
desktop_view_locked_free(desktop->locked_view);
desktop_lock_menu_free(desktop->lock_menu);
desktop_view_locked_free(desktop->locked_view);
desktop_debug_free(desktop->debug_view);
popup_free(desktop->hw_mismatch_popup);
desktop_view_pin_timeout_free(desktop->pin_timeout_view);

furi_record_close(RECORD_GUI);
desktop->gui = NULL;

furi_thread_free(desktop->scene_thread);

furi_record_close("menu");

furi_timer_free(desktop->auto_lock_timer);

free(desktop);
}

static bool desktop_check_file_flag(const char* flag_path) {
Storage* storage = furi_record_open(RECORD_STORAGE);
bool exists = storage_common_stat(storage, flag_path, NULL) == FSE_OK;
Expand Down Expand Up @@ -427,7 +375,8 @@ int32_t desktop_srv(void* p) {
}

view_dispatcher_run(desktop->view_dispatcher);
desktop_free(desktop);

furi_crash("That was unexpected");

return 0;
}
11 changes: 1 addition & 10 deletions applications/services/dolphin/dolphin.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,6 @@ Dolphin* dolphin_alloc() {
return dolphin;
}

void dolphin_free(Dolphin* dolphin) {
furi_assert(dolphin);

dolphin_state_free(dolphin->state);
furi_message_queue_free(dolphin->event_queue);

free(dolphin);
}

void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event) {
furi_assert(dolphin);
furi_assert(event);
Expand Down Expand Up @@ -204,7 +195,7 @@ int32_t dolphin_srv(void* p) {
}
}

dolphin_free(dolphin);
furi_crash("That was unexpected");

return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions applications/services/dolphin/dolphin_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ struct Dolphin {

Dolphin* dolphin_alloc();

void dolphin_free(Dolphin* dolphin);

void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event);

void dolphin_event_send_wait(Dolphin* dolphin, DolphinEvent* event);
Expand Down
26 changes: 1 addition & 25 deletions applications/services/power/power_service/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,30 +85,6 @@ Power* power_alloc() {
return power;
}

void power_free(Power* power) {
furi_assert(power);

// Gui
view_dispatcher_remove_view(power->view_dispatcher, PowerViewOff);
power_off_free(power->power_off);
view_dispatcher_remove_view(power->view_dispatcher, PowerViewUnplugUsb);
power_unplug_usb_free(power->power_unplug_usb);

view_port_free(power->battery_view_port);

// State
furi_mutex_free(power->api_mtx);

// FuriPubSub
furi_pubsub_free(power->event_pubsub);

// Records
furi_record_close(RECORD_NOTIFICATION);
furi_record_close(RECORD_GUI);

free(power);
}

static void power_check_charging_state(Power* power) {
if(furi_hal_power_is_charging()) {
if((power->info.charge == 100) || (furi_hal_power_is_charging_done())) {
Expand Down Expand Up @@ -252,7 +228,7 @@ int32_t power_srv(void* p) {
furi_delay_ms(1000);
}

power_free(power);
furi_crash("That was unexpected");

return 0;
}