[Julius-cvs 784] CVS update: julius4/libsent/src/ngram

Back to archive index

sumom****@users***** sumom****@users*****
2012年 8月 31日 (金) 14:17:29 JST


Index: julius4/libsent/src/ngram/ngram_malloc.c
diff -u julius4/libsent/src/ngram/ngram_malloc.c:1.7 julius4/libsent/src/ngram/ngram_malloc.c:1.8
--- julius4/libsent/src/ngram/ngram_malloc.c:1.7	Fri Jul 27 17:44:57 2012
+++ julius4/libsent/src/ngram/ngram_malloc.c	Fri Aug 31 14:17:28 2012
@@ -12,7 +12,7 @@
  * @author Akinobu LEE
  * @date   Wed Feb 16 16:48:56 2005
  *
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
  * 
  */
 /*
@@ -37,6 +37,7 @@
 
   new = (NGRAM_INFO *)mymalloc(sizeof(NGRAM_INFO));
   new->n = 0;
+  new->wname = NULL;
   new->d = NULL;
   new->bo_wt_1 = NULL;
   new->p_2 = NULL;
@@ -71,17 +72,22 @@
 ngram_info_free(NGRAM_INFO *ndata)
 {
   int i;
+  WORD_ID w;
+
   /* bin test only */
   /* free word names */
   if (ndata->from_bin) {
-    free(ndata->wname[0]);
-    free(ndata->wname);
+    if (ndata->wname) {
+      if (ndata->wname[0]) free(ndata->wname[0]);
+      free(ndata->wname);
+    }
   } else {
-    WORD_ID w;
-    for(w=0;w<ndata->max_word_num;w++) {
-      free(ndata->wname[w]);
+    if (ndata->wname) {
+      for(w=0;w<ndata->max_word_num;w++) {
+	if (ndata->wname[w]) free(ndata->wname[w]);
+      }
+      free(ndata->wname);
     }
-    free(ndata->wname);
   }
   /* free 2-gram for the 1st pass */
   if (ndata->bo_wt_1) free(ndata->bo_wt_1);
Index: julius4/libsent/src/ngram/ngram_read_arpa.c
diff -u julius4/libsent/src/ngram/ngram_read_arpa.c:1.19 julius4/libsent/src/ngram/ngram_read_arpa.c:1.20
--- julius4/libsent/src/ngram/ngram_read_arpa.c:1.19	Fri Jul 27 17:44:57 2012
+++ julius4/libsent/src/ngram/ngram_read_arpa.c	Fri Aug 31 14:17:28 2012
@@ -20,7 +20,7 @@
  * @author Akinobu LEE
  * @date   Wed Feb 16 16:52:24 2005
  *
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
  * 
  */
 /*
@@ -30,7 +30,7 @@
  * All rights reserved
  */
 
-/* $Id: ngram_read_arpa.c,v 1.19 2012/07/27 08:44:57 sumomo Exp $ */
+/* $Id: ngram_read_arpa.c,v 1.20 2012/08/31 05:17:28 sumomo Exp $ */
 
 /* words should be alphabetically sorted */
 
@@ -113,6 +113,9 @@
 
   /* malloc name area */
   ndata->wname = (char **)mymalloc(sizeof(char *) * ndata->max_word_num);
+  for (nid = 0; nid < ndata->max_word_num; nid++) {
+    ndata->wname[nid] = NULL;
+  }
 
   /* malloc data area */
   //t->bgn_upper = t->bgn_lower = t->bgn = t->num = NULL;
Index: julius4/libsent/src/ngram/ngram_read_bin.c
diff -u julius4/libsent/src/ngram/ngram_read_bin.c:1.10 julius4/libsent/src/ngram/ngram_read_bin.c:1.11
--- julius4/libsent/src/ngram/ngram_read_bin.c:1.10	Fri Jul 27 17:44:57 2012
+++ julius4/libsent/src/ngram/ngram_read_bin.c	Fri Aug 31 14:17:28 2012
@@ -48,7 +48,7 @@
  * @author Akinobu LEE
  * @date   Wed Feb 16 17:12:08 2005
  *
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
  * 
  */
 /*
@@ -267,6 +267,7 @@
   rdn(fp, w, 1, len);
   /* assign... */
   ndata->wname = (char **)mymalloc(sizeof(char *) * ndata->max_word_num);
+  ndata->wname[0] = NULL;
   p = w; i = 0;
   while (p < w + len) {
     ndata->wname[i++] = p;



Julius-cvs メーリングリストの案内
Back to archive index