Fixed error: Syscall param write(buf) points to uninitialised byte(s)
authornvalimak <nvalimak@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Tue, 21 Apr 2009 07:58:44 +0000 (07:58 +0000)
committernvalimak <nvalimak@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Tue, 21 Apr 2009 07:58:44 +0000 (07:58 +0000)
git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@342 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

libcds/src/static_sequence/static_sequence_wvtree.cpp

index b4a6298..5030fb1 100644 (file)
@@ -22,6 +22,7 @@
 #include <static_sequence_wvtree.h>
 
 static_sequence_wvtree::static_sequence_wvtree(uint * symbols, uint n, wt_coder * c, static_bitsequence_builder * bmb, alphabet_mapper * am) {
+    this->n = n;
   for(uint i=0;i<n;i++) 
     symbols[i] = am->map(symbols[i]);
   this->am = am;
@@ -34,6 +35,7 @@ static_sequence_wvtree::static_sequence_wvtree(uint * symbols, uint n, wt_coder
 }
 
 static_sequence_wvtree::static_sequence_wvtree(uchar * symbols, uint n, wt_coder * c, static_bitsequence_builder * bmb, alphabet_mapper * am) {
+    this->n = n;
   for(uint i=0;i<n;i++) 
     symbols[i] = (uchar)am->map((uint)symbols[i]);
   this->am = am;
@@ -124,12 +126,17 @@ uint static_sequence_wvtree::size() {
 uint static_sequence_wvtree::save(FILE * fp) { 
   uint wr = WVTREE_HDR;
   wr = fwrite(&wr,sizeof(uint),1,fp);
+  fflush(fp);
   if(wr!=1) return 1;
   wr = fwrite(&n,sizeof(uint),1,fp);
+  fflush(fp);
   if(wr!=1) return 1;
   if(c->save(fp)) return 1;
+  fflush(fp);
   if(am->save(fp)) return 1;
+  fflush(fp);
   if(root->save(fp)) return 1;
+  fflush(fp);
   return 0;
 }