Skip to content

Commit acc601a

Browse files
committed
Fix some memory leaks.
Signed-off-by: Katharine Berry <ktbry@google.com>
1 parent d907337 commit acc601a

File tree

11 files changed

+23
-2
lines changed

11 files changed

+23
-2
lines changed

app/src/c/alarms/alarm_window.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ static void prv_window_unload(Window *window) {
123123
vector_sequence_layer_destroy(data->animation_layer);
124124
events_tick_timer_service_unsubscribe(data->tick_handle);
125125
free(data);
126+
window_destroy(window);
126127
}
127128

128129
static void prv_window_appear(Window *window) {

app/src/c/converse/segments/info_layer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ InfoLayer* info_layer_create(GRect rect, ConversationEntry* entry) {
4343
Layer* layer = layer_create_with_data(rect, sizeof(InfoLayerData));
4444
InfoLayerData* data = layer_get_data(layer);
4545
data->entry = entry;
46+
data->icon = NULL;
4647
data->content_text = NULL;
4748
data->content_height = 24;
4849
data->content_height = prv_get_content_height(layer);
@@ -64,6 +65,10 @@ void info_layer_destroy(InfoLayer* layer) {
6465
if (data->content_text) {
6566
free(data->content_text);
6667
}
68+
if (data->icon) {
69+
gdraw_command_image_destroy(data->icon);
70+
}
71+
layer_destroy(layer);
6772
}
6873

6974
ConversationEntry* info_layer_get_entry(InfoLayer* layer) {

app/src/c/converse/segments/message_layer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ void message_layer_destroy(MessageLayer* layer) {
6363
text_layer_destroy(data->speaker_layer);
6464
}
6565
text_layer_destroy(data->content_layer);
66+
layer_destroy(layer);
6667
}
6768

6869
void message_layer_update(MessageLayer* layer) {

app/src/c/converse/segments/segment_layer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void segment_layer_destroy(SegmentLayer* layer) {
7575
info_layer_destroy(data->info_layer);
7676
break;
7777
}
78+
layer_destroy(layer);
7879
}
7980

8081
ConversationEntry* segment_layer_get_entry(SegmentLayer* layer) {

app/src/c/converse/session_window.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static void prv_destroy(SessionWindow *sw) {
7474
scroll_layer_destroy(sw->scroll_layer);
7575
bitmap_layer_destroy(sw->button_layer);
7676
gbitmap_destroy(sw->button_bitmap);
77+
layer_destroy(sw->scroll_indicator_down);
7778
if (sw->thinking_layer) {
7879
thinking_layer_destroy(sw->thinking_layer);
7980
sw->thinking_layer = NULL;
@@ -82,6 +83,8 @@ static void prv_destroy(SessionWindow *sw) {
8283
segment_layer_destroy(sw->segment_layers[i]);
8384
}
8485
free(sw->segment_layers);
86+
window_destroy(sw->window);
87+
free(sw);
8588
}
8689

8790
static void prv_window_load(Window *window) {

app/src/c/menus/alarm_menu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ static void prv_window_unload(Window* window) {
121121
if (data->sleeping_horse_image != NULL) {
122122
gdraw_command_image_destroy(data->sleeping_horse_image);
123123
}
124+
window_destroy(window);
124125
free(data);
125126
}
126127

app/src/c/menus/legal_window.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,5 @@ static void prv_window_unload(Window* window) {
7070
scroll_layer_destroy(data->scroll_layer);
7171
status_bar_layer_destroy(data->status_bar);
7272
free(data);
73+
window_destroy(window);
7374
}

app/src/c/menus/quota_window.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ static void prv_window_unload(Window* window) {
8383
vector_sequence_layer_destroy(data->loading_layer);
8484
gdraw_command_sequence_destroy(data->loading_sequence);
8585
events_app_message_unsubscribe(data->app_message_handle);
86+
scroll_layer_destroy(data->scroll_layer);
87+
status_bar_layer_destroy(data->status_bar);
8688
free(data);
89+
window_destroy(window);
8790
}
8891

8992
static void prv_fetch_quota(Window* window) {
@@ -108,9 +111,11 @@ static void prv_app_message_received(DictionaryIterator* iter, void* context) {
108111
}
109112
int remaining = tuple->value->int32;
110113
APP_LOG(APP_LOG_LEVEL_INFO, "Quota: %d used, %d remaining", used, remaining);
111-
snprintf(data->explanation, sizeof(data->explanation), "You've used %d%% of your Bobby quota for this month. Once you've used 100%%, Bobby will stop working until next month. Quota resets on the first day of each month.", ((used * 100) / (used + remaining)));
114+
int display_percent = (int)(((uint64_t)used * 100) / (used + remaining));
115+
uint64_t percentage = ((uint64_t)used * PERCENTAGE_MAX) / (used + remaining);
116+
snprintf(data->explanation, sizeof(data->explanation), "You've used %d%% of your Bobby quota for this month. Once you've used 100%%, Bobby will stop working until next month. Quota resets on the first day of each month.", display_percent);
112117
text_layer_set_text(data->explanation_layer, data->explanation);
113-
usage_layer_set_percentage(data->usage_layer, (int16_t)((used * PERCENTAGE_MAX) / (used + remaining)));
118+
usage_layer_set_percentage(data->usage_layer, (int16_t)percentage);
114119
vector_sequence_layer_stop(data->loading_layer);
115120
layer_remove_from_parent(data->loading_layer);
116121
layer_add_child(root_layer, (Layer *)data->scroll_layer);

app/src/c/menus/root_menu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static void prv_window_unload(Window* window) {
9191
simple_menu_layer_destroy(data->menu_layer);
9292
status_bar_layer_destroy(data->status_bar);
9393
free(data);
94+
window_destroy(window);
9495
}
9596

9697
static void prv_push_quota_screen(int index, void* context) {

app/src/c/util/result_window.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ static void prv_window_unload(Window* window) {
104104
free(data->title_text);
105105
free(data->text_text);
106106
free(data);
107+
window_destroy(window);
107108
}
108109

109110
static void prv_window_appear(Window* window) {

0 commit comments

Comments
 (0)