[uim-commit] r659 - trunk/uim

tkng at freedesktop.org tkng at freedesktop.org
Tue Feb 15 04:08:00 PST 2005


Author: tkng
Date: 2005-02-15 04:07:45 -0800 (Tue, 15 Feb 2005)
New Revision: 659

Modified:
   trunk/uim/m17nlib.c
Log:
* uim/m17nlib.c:
 -(fill_new_candidates): Fixed a memory leak.
 -(old_cands_free): Fixed an inifinite loop condition.


Modified: trunk/uim/m17nlib.c
===================================================================
--- trunk/uim/m17nlib.c	2005-02-15 11:28:27 UTC (rev 658)
+++ trunk/uim/m17nlib.c	2005-02-15 12:07:45 UTC (rev 659)
@@ -621,12 +621,38 @@
   return uim_scm_f();
 }
 
+static int
+calc_cands_num(int id)
+{
+  int result = 0;
+  MPlist *group; 
+  MInputContext *ic = ic_array[id].mic;
+
+  if(!ic || !ic->candidate_list)
+    return 0;
+
+  group = ic->candidate_list;
+
+  while(mplist_value(group) != Mnil) {
+    if(mplist_key(group) == Mtext) {
+      for (; mplist_key(group) != Mnil; group = mplist_next(group)) {
+        result += mtext_len(mplist_value(group));
+      }
+    } else {
+      for (; mplist_key(group) != Mnil; group = mplist_next(group)) {
+        result += mplist_length(mplist_value(group));
+      }
+    }
+  }
+  return result;
+}
+
 static void
 old_cands_free(char **old_cands)
 {
   int i = 0;
   if(old_cands) {
-    while(old_cands[i]){
+    for(i=0; old_cands[i]; i++) {
       free(old_cands[i]);
     }
     free(old_cands);
@@ -652,6 +678,7 @@
 
   group = ic->candidate_list;
 
+  old_cands_free(ic_array[id].old_candidates);
   ic_array[id].old_candidates = ic_array[id].new_candidates;
 
   new_cands = malloc (cands_num * sizeof(char *) + 2);
@@ -720,33 +747,6 @@
   return uim_scm_f();
 }
 
-int
-calc_cands_num(int id)
-{
-  int result = 0;
-  MPlist *group; 
-  MInputContext *ic = ic_array[id].mic;
-
-  if(!ic || !ic->candidate_list)
-    return 0;
-
-  group = ic->candidate_list;
-
-  while(mplist_value(group) != Mnil) {
-    if(mplist_key(group) == Mtext) {
-      for (; mplist_key(group) != Mnil; group = mplist_next(group)) {
-        result += mtext_len(mplist_value(group));
-      }
-    } else {
-      for (; mplist_key(group) != Mnil; group = mplist_next(group)) {
-        result += mplist_length(mplist_value(group));
-      }
-    }
-  }
-  return result;
-}
-
-
 static uim_lisp
 get_nr_candidates(uim_lisp id_)
 {



More information about the Uim-commit mailing list