This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch main
in repository eradio.
View the commit online.
commit a1fc012be7fba7534140e38561590fa79da25b71
Author: politebot <[email protected]>
AuthorDate: Sat Oct 11 08:01:47 2025 -0500
Memory fixes
---
src/favorites.c | 13 +++++++++----
src/http.c | 43 ++++++++++++++++---------------------------
src/radio_player.c | 1 +
src/station_list.c | 9 ++++++++-
src/ui.c | 52 ++++++++++++++++++++++++++--------------------------
5 files changed, 60 insertions(+), 58 deletions(-)
diff --git a/src/favorites.c b/src/favorites.c
index 87749cf..e08d1c4 100644
--- a/src/favorites.c
+++ b/src/favorites.c
@@ -247,11 +247,16 @@ static Eina_Bool _favorites_rebuild_cb(const Eina_Hash *hash EINA_UNUSED, const
void favorites_rebuild_station_list(AppData *ad)
{
- // free previous list items (shallow as per existing patterns)
- if (ad->favorites_stations)
+ Station *st;
+ EINA_LIST_FREE(ad->favorites_stations, st)
{
- eina_list_free(ad->favorites_stations);
- ad->favorites_stations = NULL;
+ eina_stringshare_del(st->name);
+ eina_stringshare_del(st->url);
+ eina_stringshare_del(st->favicon);
+ eina_stringshare_del(st->stationuuid);
+ free(st);
}
+ ad->favorites_stations = NULL;
+
eina_hash_foreach(ad->favorites, _favorites_rebuild_cb, ad);
}
\ No newline at end of file
diff --git a/src/http.c b/src/http.c
index c8b03a5..a7f17c4 100644
--- a/src/http.c
+++ b/src/http.c
@@ -111,6 +111,7 @@ http_search_stations(AppData *ad, const char *search_term, const char *search_ty
void
http_station_click_counter(AppData *ad, const char *uuid)
{
+ fprintf(stderr, "LOG: http_station_click_counter: ad=%p, uuid=%s\n", ad, uuid);
if (!uuid || !uuid[0]) return;
Counter_Download_Context *c_ctx = calloc(1, sizeof(Counter_Download_Context));
@@ -351,6 +352,7 @@ _handle_station_list_complete(Ecore_Con_Event_Url_Complete *ev)
ui_set_load_more_button_visibility(ad, EINA_FALSE);
}
+ eina_list_free(d_ctx->servers);
free(d_ctx);
xmlXPathFreeObject(xpathObj);
@@ -399,7 +401,9 @@ _url_complete_cb(void *data, int type, void *event_info)
return ECORE_CALLBACK_PASS_ON;
}
// No further action needed; just free context
- free(ctx);
+ Counter_Download_Context *c_ctx = (Counter_Download_Context *)ctx;
+ eina_list_free(c_ctx->servers);
+ free(c_ctx);
}
ecore_con_url_free(ev->url_con);
@@ -465,23 +469,9 @@ static void _refresh_api_servers(AppData *ad)
static void _randomize_servers(AppData *ad)
{
- // Fisher-Yates shuffle on an array copy of the list
- int n = eina_list_count(ad->api_servers);
- if (n <= 1) return;
- char **arr = calloc(n, sizeof(char *));
- Eina_List *l; const char *h; int i = 0;
- EINA_LIST_FOREACH(ad->api_servers, l, h) arr[i++] = (char *)h;
- srand((unsigned int)time(NULL));
- for (int j = n - 1; j > 0; j--)
- {
- int k = rand() % (j + 1);
- char *tmp = arr[j]; arr[j] = arr[k]; arr[k] = tmp;
- }
- // rebuild list in randomized order
- eina_list_free(ad->api_servers);
- ad->api_servers = NULL;
- for (int j = 0; j < n; j++) ad->api_servers = eina_list_append(ad->api_servers, arr[j]);
- free(arr);
+ if (!ad->api_servers) return;
+ srand(time(NULL));
+ ad->api_servers = eina_list_shuffle(ad->api_servers, NULL);
}
static const char *_primary_server(AppData *ad)
@@ -493,21 +483,17 @@ static const char *_primary_server(AppData *ad)
static void _prepend_selected_as_primary(Eina_List **list, const char *selected)
{
if (!selected || !list) return;
- Eina_List *l; const char *h; Eina_List *node = NULL;
- EINA_LIST_FOREACH(*list, l, h)
+ Eina_List *l, *l_next;
+ const char *h;
+ EINA_LIST_FOREACH_SAFE(*list, l, l_next, h)
{
if ((h == selected) || (h && selected && strcmp(h, selected) == 0))
{
- node = l;
+ *list = eina_list_remove_list(*list, l);
+ *list = eina_list_prepend(*list, h);
break;
}
}
- if (node)
- {
- const char *data = ""
- *list = eina_list_remove_list(*list, node);
- *list = eina_list_prepend(*list, data);
- }
}
static void _populate_station_request(Station_Download_Context *d_ctx, AppData *ad, const char *search_type, const char *search_term, const char *order, Eina_Bool reverse)
@@ -568,12 +554,14 @@ static void _retry_next_server_station(Ecore_Con_Url *old_url, Station_Download_
xmlFreeParserCtxt(d_ctx->ctxt);
d_ctx->ctxt = NULL;
}
+ eina_list_free(d_ctx->servers);
free(d_ctx);
}
}
static void _populate_counter_request(Counter_Download_Context *c_ctx, AppData *ad, const char *uuid)
{
+ fprintf(stderr, "LOG: _populate_counter_request: ad=%p, ad->api_servers=%p\n", ad, ad ? ad->api_servers : NULL);
strncpy(c_ctx->stationuuid, uuid, sizeof(c_ctx->stationuuid) - 1);
c_ctx->servers = eina_list_clone(ad->api_servers);
_prepend_selected_as_primary(&c_ctx->servers, ad->api_selected);
@@ -609,6 +597,7 @@ static void _retry_next_server_counter(Ecore_Con_Url *old_url, Counter_Download_
{
printf("All servers exhausted for counter; giving up.\n");
ecore_con_url_free(old_url);
+ eina_list_free(c_ctx->servers);
free(c_ctx);
}
}
diff --git a/src/radio_player.c b/src/radio_player.c
index 94c153b..e6fa356 100644
--- a/src/radio_player.c
+++ b/src/radio_player.c
@@ -15,6 +15,7 @@ radio_player_shutdown(void)
void
radio_player_play(AppData *ad, const char *url)
{
+ fprintf(stderr, "LOG: radio_player_play: ad=%p, url="" ad, url);
if (url && url[0])
{
emotion_object_file_set(ad->emotion, url);
diff --git a/src/station_list.c b/src/station_list.c
index eca03a0..b28060c 100644
--- a/src/station_list.c
+++ b/src/station_list.c
@@ -10,7 +10,9 @@ static void _favorite_remove_btn_clicked_cb(void *data, Evas_Object *obj, void *
static void
_station_click_counter_request(AppData *ad, Station *st)
{
+ fprintf(stderr, "LOG: _station_click_counter_request: ad=%p, st=%p\n", ad, st);
if (!st || !st->stationuuid) return;
+ fprintf(stderr, "LOG: _station_click_counter_request: stationuuid=%s\n", st->stationuuid);
http_station_click_counter(ad, st->stationuuid);
}
@@ -21,8 +23,12 @@ _list_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
Elm_Object_Item *it = event_info;
Station *st = elm_object_item_data_get(it);
+ fprintf(stderr, "LOG: _list_item_selected_cb: ad=%p, it=%p, st=%p\n", ad, it, st);
+
if (!st) return;
+ fprintf(stderr, "LOG: _list_item_selected_cb: station name='%s', url="" st->name, st->url);
+
_station_click_counter_request(ad, st);
radio_player_play(ad, st->url);
}
@@ -65,8 +71,9 @@ station_list_populate(AppData *ad, Eina_List *stations, Eina_Bool new_search)
elm_object_text_set(fav_btn, "Remove");
}
- Elm_Object_Item *li = elm_list_item_append(ad->list, st->name, icon, fav_btn, _list_item_selected_cb, ad);
+ Elm_Object_Item *li = elm_list_item_append(ad->list, st->name, icon, fav_btn, NULL, NULL);
elm_object_item_data_set(li, st);
+ evas_object_smart_callback_add(ad->list, "selected", _list_item_selected_cb, ad);
// Attach callback only when a button exists
if (fav_btn)
diff --git a/src/ui.c b/src/ui.c
index 92f10c0..1162006 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -155,11 +155,11 @@ ui_create(AppData *ad)
evas_object_show(ad->reverse_check);
// Server selection hoversel, populated after HTTP init discovers servers
- /* ad->server_hoversel = elm_hoversel_add(ad->win); */
- /* elm_hoversel_hover_parent_set(ad->server_hoversel, ad->win); */
- /* elm_object_text_set(ad->server_hoversel, "server"); */
- /* elm_box_pack_end(ad->search_bar, ad->server_hoversel); */
- /* evas_object_show(ad->server_hoversel); */
+ ad->server_hoversel = elm_hoversel_add(ad->win);
+ elm_hoversel_hover_parent_set(ad->server_hoversel, ad->win);
+ elm_object_text_set(ad->server_hoversel, "server");
+ elm_box_pack_end(ad->search_bar, ad->server_hoversel);
+ evas_object_show(ad->server_hoversel);
ad->search_btn = elm_button_add(ad->win);
elm_object_text_set(ad->search_btn, "Search");
@@ -232,29 +232,29 @@ ui_create(AppData *ad)
void ui_update_server_list(AppData *ad)
{
- /* if (!ad || !ad->server_hoversel) return; */
- /* Eina_List *l; const char *host; */
- /* EINA_LIST_FOREACH(ad->api_servers, l, host) */
- /* { */
- /* elm_hoversel_item_add(ad->server_hoversel, host, NULL, ELM_ICON_NONE, _server_item_selected_cb, ad); */
- /* } */
- /* if (ad->api_selected && ad->api_selected[0]) */
- /* elm_object_text_set(ad->server_hoversel, ad->api_selected); */
+ if (!ad || !ad->server_hoversel) return;
+ Eina_List *l; const char *host;
+ EINA_LIST_FOREACH(ad->api_servers, l, host)
+ {
+ elm_hoversel_item_add(ad->server_hoversel, host, NULL, ELM_ICON_NONE, _server_item_selected_cb, ad);
+ }
+ if (ad->api_selected && ad->api_selected[0])
+ elm_object_text_set(ad->server_hoversel, ad->api_selected);
}
-/* static void _server_item_selected_cb(void *data, Evas_Object *obj, void *event_info) */
-/* { */
-/* AppData *ad = data; */
-/* if (!ad) return; */
-/* Elm_Object_Item *it = event_info; */
-/* const char *label = elm_object_item_text_get(it); */
-/* if (label && label[0]) */
-/* { */
-/* elm_object_text_set(obj, label); */
-/* if (ad->api_selected) eina_stringshare_del(ad->api_selected); */
-/* ad->api_selected = eina_stringshare_add(label); */
-/* } */
-/* } */
+static void _server_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ AppData *ad = data;
+ if (!ad) return;
+ Elm_Object_Item *it = event_info;
+ const char *label = elm_object_item_text_get(it);
+ if (label && label[0])
+ {
+ elm_object_text_set(obj, label);
+ if (ad->api_selected) eina_stringshare_del(ad->api_selected);
+ ad->api_selected = eina_stringshare_add(label);
+ }
+}
static void
_tb_favorites_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.