Great Circle Associates

XCIN Mail-list
(January 2001)


Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Re: program using libtabe
From: Kuang-che Wu <kcwu@ck.tp.edu.tw>
Date: Sat, 6 Jan 2001 22:26:30 +0800
To: xcin@linux.org.tw
Delivered-To: xcin-gate@tlug.sinica.edu.tw
Delivered-To: xcin-list@tlug.sinica.edu.tw
Reply-To: xcin@tlug.sinica.edu.tw
User-Agent: Mutt/1.2.4i

On Fri, Jan 05, 2001 at 09:29:53PM +0800, Kuang-che Wu wrote:
> 我寫了一個小程式, 使用 libtabe,
> 程式 output 了奇怪的東西,
忘了說明, 我的程式很簡單, 只是仿照 tsidump
打算寫一個 yindump 而已
> 但我對 libtabe 不熟, 不曉得是我的程式還是 libtabe 的問題
> 放上來請大家幫忙看看
找到 libtabe 的一個小 bug, 改了之後我的程式看起 output 比較正常
可是還是不太正確, 可能是我改錯了甚麼, 不然就是某處還有 bug
可是我已經找不太到那兒有問題了....

--- tabe_tsiyindbint.c.old      Sat Jan  6 22:22:46 2001
+++ tabe_tsiyindbint.c  Sat Jan  6 18:44:44 2001
@@ -407,8 +407,8 @@
     free(tsiyin->yin);
     tsiyin->yin = (Yin *)NULL;
   }
-  tsiyin->yin = (Yin *)malloc(sizeof(Yin)*tsiyin->yinlen);
-  memcpy(tsiyin->yin, key.data, sizeof(Yin)*tsiyin->yinlen);
+  tsiyin->yin = (Yin *)malloc(key.size);
+  memcpy(tsiyin->yin, key.data, key.size);

   TsiYinDBUnpackDataDB(tsiyin, &dat);

@@ -445,8 +445,8 @@
     free(tsiyin->yin);
     tsiyin->yin = (Yin *)NULL;
   }
-  tsiyin->yin = (Yin *)malloc(sizeof(Yin)*tsiyin->yinlen);
-  memcpy(tsiyin->yin, key.data, sizeof(Yin)*tsiyin->yinlen);
+  tsiyin->yin = (Yin *)malloc(key.size);
+  memcpy(tsiyin->yin, key.data, key.size);

   TsiYinDBUnpackDataDB(tsiyin, &dat);

@@ -483,8 +483,8 @@
     free(tsiyin->yin);
     tsiyin->yin = (Yin *)NULL;
   }
-  tsiyin->yin = (Yin *)malloc(sizeof(Yin)*tsiyin->yinlen);
-  memcpy(tsiyin->yin, key.data, sizeof(Yin)*tsiyin->yinlen);
+  tsiyin->yin = (Yin *)malloc(key.size);
+  memcpy(tsiyin->yin, key.data, key.size);

   TsiYinDBUnpackDataDB(tsiyin, &dat);

To Unsubscribe: send mail to majordomo@linux.org.tw
with "unsubscribe xcin" in the body of the message



Follow-Ups:
References:
Indexed By Date Previous: Re: Add Tsi
From: Kuang-che Wu <kcwu@ck.tp.edu.tw>
Next: Re: Add Tsi
From: Edward Lee <edward.@kimo.com>
Indexed By Thread Previous: program using libtabe
From: Kuang-che Wu <kcwu@ck.tp.edu.tw>
Next: Re: program using libtabe
From: Kuang-che Wu <kcwu@ck.tp.edu.tw>