discomfitor pushed a commit to branch master.

http://git.enlightenment.org/apps/empc.git/commit/?id=f501bb454200beecafcf88e71c235aa5b1aa422a

commit f501bb454200beecafcf88e71c235aa5b1aa422a
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Mon Feb 8 11:52:46 2016 -0500

    convert array usage in empdd to lists
---
 src/bin/empdd.c | 47 +++++++++++++++--------------------------------
 1 file changed, 15 insertions(+), 32 deletions(-)

diff --git a/src/bin/empdd.c b/src/bin/empdd.c
index bdc3ada..94dafea 100644
--- a/src/bin/empdd.c
+++ b/src/bin/empdd.c
@@ -35,8 +35,8 @@ typedef struct EMPD
    struct mpd_parser *parser;
 
 
-   Eina_Array *pending;
-   Eina_Array *current_queue;
+   Eina_List *pending;
+   Eina_List *current_queue;
    void *cur;
    E_Slist *cmds, *last;
 
@@ -344,7 +344,7 @@ static void
 queue_list_send(Eldbus_Message *msg, unsigned int start, long num)
 {
    Eldbus_Message_Iter *iter, *array, *struc;
-   Eina_Iterator *it;
+   Eina_List *l;
    struct mpd_song *so;
    unsigned int cur = 0;
    Eina_Bool sig = !msg;
@@ -353,8 +353,7 @@ queue_list_send(Eldbus_Message *msg, unsigned int start, 
long num)
      msg = eldbus_service_signal_new(empd_iface, EMPD_SIGNAL_QUEUE_LIST);
    iter = eldbus_message_iter_get(msg);
    array = eldbus_message_iter_container_new(iter, 'a', "(stusssisssii)");
-   it = eina_array_iterator_new(empd->current_queue);
-   EINA_ITERATOR_FOREACH(it, so)
+   EINA_LIST_FOREACH(queue_list, l, so)
      {
         /* holy shit. */
         const char *track = mpd_song_get_tag(so, MPD_TAG_TRACK, 0);
@@ -370,7 +369,6 @@ queue_list_send(Eldbus_Message *msg, unsigned int start, 
long num)
         eldbus_message_iter_container_close(array, struc);
         if (mpd_song_get_pos(so) == num) break;
      }
-   eina_iterator_free(it);
    eldbus_message_iter_container_close(iter, array);
    if (sig)
      eldbus_service_signal_send(empd_iface, msg);
@@ -555,12 +553,12 @@ fdh_func(void *d EINA_UNUSED, Ecore_Fd_Handler *fdh 
EINA_UNUSED)
                      mpd_status_get_next_song_pos(st), 
mpd_status_get_next_song_id(st), empd_dbupdate);
                    if (((!empd->current_queue) && 
(!mpd_status_get_queue_length(st))) ||
                        ((!empd_queue_version) && empd->current_queue &&
-                       (eina_array_count(empd->current_queue) == 
mpd_status_get_queue_length(st))))
+                       (eina_list_count(empd->current_queue) == 
mpd_status_get_queue_length(st))))
                      empd_queue_version = mpd_status_get_queue_version(st);
                    if ((empd_queue_version && (empd_queue_version != 
mpd_status_get_queue_version(st))) ||
                        ((!empd->current_queue) && 
(mpd_status_get_queue_length(st))) ||
                        (empd->current_queue && mpd_status_get_queue_length(st) 
&&
-                        (eina_array_count(empd->current_queue) != 
mpd_status_get_queue_length(st))))
+                        (eina_list_count(empd->current_queue) != 
mpd_status_get_queue_length(st))))
                      {
                         if (queue_fetch())
                           empd_queue_version = 
mpd_status_get_queue_version(st);
@@ -622,12 +620,10 @@ fdh_func(void *d EINA_UNUSED, Ecore_Fd_Handler *fdh 
EINA_UNUSED)
                      {
                         if (!strcmp(name, "Id"))
                           {
-                             /* at end of current song, push to array
+                             /* at end of current song, push to list
                               * for sending all at once later
                               */
-                             if (!empd->pending)
-                               empd->pending = eina_array_new(10);
-                             eina_array_push(empd->pending, so);
+                             empd->pending = eina_list_append(empd->pending, 
so);
                              empd->cur = NULL;
                           }
                      }
@@ -654,11 +650,7 @@ fdh_func(void *d EINA_UNUSED, Ecore_Fd_Handler *fdh 
EINA_UNUSED)
                 {
                    if (res != MPD_PARSER_SUCCESS)
                      break;
-                   if (empd->current_queue)
-                     {
-                        eina_array_foreach(empd->current_queue, 
queue_item_each_free, NULL);
-                        eina_array_free(empd->current_queue);
-                     }
+                   E_FREE_LIST(empd->current_queue, mpd_song_free);
                    empd->current_queue = empd->pending;
                    empd->pending = NULL;
                    if (empd->current_queue)
@@ -673,13 +665,11 @@ fdh_func(void *d EINA_UNUSED, Ecore_Fd_Handler *fdh 
EINA_UNUSED)
 
               if (res == MPD_PARSER_PAIR)
                 {
-                   if (!empd->pending)
-                     empd->pending = eina_array_new(10);
                    //fprintf(stderr, "[%s]|FEED\n", cmd_txt[cmd_get()]);
                    if ((!empd->cur) || (!mpd_entity_feed(empd->cur, &(struct 
mpd_pair){name, value})))
                      {
                         empd->cur = mpd_entity_begin(&(struct mpd_pair){name, 
value});
-                        eina_array_push(empd->pending, empd->cur);
+                        empd->pending = eina_list_append(empd->pending, 
empd->cur);
                      }
                 }
               else if (res == MPD_PARSER_ERROR)
@@ -698,7 +688,6 @@ fdh_func(void *d EINA_UNUSED, Ecore_Fd_Handler *fdh 
EINA_UNUSED)
                 }
               else
                 {
-                   Eina_Iterator *it = NULL;
                    struct mpd_entity *ent;
                    Eldbus_Message *msg;
                    Eldbus_Message_Iter *iter, *array;
@@ -709,9 +698,7 @@ fdh_func(void *d EINA_UNUSED, Ecore_Fd_Handler *fdh 
EINA_UNUSED)
                    msg = empd->cmds->data;
                    iter = eldbus_message_iter_get(msg);
                    array = eldbus_message_iter_container_new(iter, 'a', 
"(iv)");
-                   if (empd->pending)
-                     it = eina_array_iterator_new(empd->pending);
-                   EINA_ITERATOR_FOREACH(it, ent)
+                   EINA_LIST_FREE(empd->pending, ent)
                      {
                         const struct mpd_song *so;
                         const struct mpd_playlist *pl;
@@ -751,22 +738,18 @@ fdh_func(void *d EINA_UNUSED, Ecore_Fd_Handler *fdh 
EINA_UNUSED)
                              eldbus_message_iter_arguments_append(s2, "st",
                                mpd_directory_get_path(dir), 
mpd_directory_get_last_modified(dir));
                              break;
-                           default: continue;
+                           default:
+                             mpd_entity_free(ent);
+                             continue;
                           }
                         eldbus_message_iter_container_close(variant, s2);
                         eldbus_message_iter_container_close(struc, variant);
                         eldbus_message_iter_container_close(array, struc);
+                        mpd_entity_free(ent);
                      }
-                   eina_iterator_free(it);
                    eldbus_message_iter_container_close(iter, array);
                    eldbus_connection_send(dbus_conn, msg, NULL, NULL, -1);
                    empd->cur = NULL;
-                   if (empd->pending)
-                     {
-                        eina_array_foreach(empd->pending, 
lsinfo_item_each_free, NULL);
-                        eina_array_free(empd->pending);
-                        empd->pending = NULL;
-                     }
                 }
            }
              break;

-- 


Reply via email to