summaryrefslogtreecommitdiffstats
path: root/utils/training
diff options
context:
space:
mode:
Diffstat (limited to 'utils/training')
-rw-r--r--utils/training/gen_deleted_ngram.cpp7
-rw-r--r--utils/training/gen_ngram.cpp6
2 files changed, 8 insertions, 5 deletions
diff --git a/utils/training/gen_deleted_ngram.cpp b/utils/training/gen_deleted_ngram.cpp
index a061136..6db511d 100644
--- a/utils/training/gen_deleted_ngram.cpp
+++ b/utils/training/gen_deleted_ngram.cpp
@@ -78,8 +78,8 @@ int main(int argc, char * argv[]){
Bigram bigram;
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) )
@@ -127,6 +127,7 @@ int main(int argc, char * argv[]){
delete single_gram;
}
}
-
+ free(linebuf);
+
return 0;
}
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);