speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] fix another loop


From: Trevor Saunders
Subject: [PATCH 2/2] fix another loop
Date: Mon, 23 Aug 2010 07:53:48 -0400

 the output_modules case of the LISt command had another loop where a
linked list was indexed into instead of using next pointers.
---
 src/server/parse.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/server/parse.c b/src/server/parse.c
index 17f24eb..eae7d4e 100644
--- a/src/server/parse.c
+++ b/src/server/parse.c
@@ -827,23 +827,24 @@ parse_list(const char* buf, const int bytes, const int 
fd, const TSpeechDSock *s
                 OK_VOICE_LIST_SENT);
         return voice_list;
     }else if(TEST_CMD(list_type, "output_modules")){
-       GString *result;
+        GString *result = g_string_new("");
        char *helper;
-       GList *gl;
-       int i;
-       int len;
-       result = g_string_new("");
-       len = g_list_length(output_modules_list);
-       MSG(1, "G LIST LENGHT IS %d", len);
-       for (i=0; i<=len-1; i++){
-         gl = g_list_nth(output_modules_list, i);
-         assert(gl!=NULL);
-         if (gl->data == NULL) continue;
-         g_string_append_printf(result, C_OK_MODULES"-%s\r\n", (char*) 
gl->data);
-       }
+       GList *cur_ptr = output_modules_list;
+
+       while(cur_ptr){
+           if (cur_ptr->data != NULL){
+               g_string_append_printf(result, C_OK_MODULES"-%s\r\n", (char*) 
cur_ptr->data);
+           }else{
+                MSG(2, "null entry in output modules list");
+           }
+
+            cur_ptr = cur_ptr->next;
+        }
+
        g_string_append(result, OK_MODULES_LIST_SENT);
        helper = result->str;
        g_string_free(result, 0);
+
         return helper;
     }else if(TEST_CMD(list_type, "synthesis_voices")){
       char *module_name;
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]