From 13dc86d5c66157fa113a4e4d88720339939fabb5 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 9 May 2011 11:20:20 +0800 Subject: fixes linebuf --- utils/training/gen_ngram.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'utils/training/gen_ngram.cpp') diff --git a/utils/training/gen_ngram.cpp b/utils/training/gen_ngram.cpp index 2ade331..71ec3f8 100644 --- a/utils/training/gen_ngram.cpp +++ b/utils/training/gen_ngram.cpp @@ -91,8 +91,8 @@ int main(int argc, char * argv[]){ bigram.attach(bigram_filename, ATTACH_CREATE|ATTACH_READWRITE); - char* linebuf = (char *)malloc ( 1024 * sizeof (char) ); - size_t size = 1024; + char* linebuf = NULL; + size_t size = 0; phrase_token_t last_token, cur_token = last_token = 0; while( getline(&linebuf, &size, stdin) ){ if ( feof(stdin) ) @@ -144,6 +144,8 @@ int main(int argc, char * argv[]){ delete single_gram; } } + + free(linebuf); MemoryChunk * new_chunk = new MemoryChunk; phrase_index.store(1, new_chunk); -- cgit