Using uint32 instead of size_t to parse the Pinyin dictionary

Because size_t is 8 bytes, So we should use uint32 which is 4 bytes to parse the Google
Pinyin dictionary.

Change-Id: I270e8d7fdee5667791a11e36f5de64687d4d0e99
Signed-off-by: jli119X <jianpingx.li@intel.com>
diff --git a/jni/include/dictdef.h b/jni/include/dictdef.h
index 3e79d98..5e1d781 100644
--- a/jni/include/dictdef.h
+++ b/jni/include/dictdef.h
@@ -109,8 +109,8 @@
  * A node occupies 16 bytes. so, totallly less than 16 * 500 = 8K
  */
 struct LmaNodeLE0 {
-  size_t son_1st_off;
-  size_t homo_idx_buf_off;
+  uint32 son_1st_off;
+  uint32 homo_idx_buf_off;
   uint16 spl_idx;
   uint16 num_of_son;
   uint16 num_of_homo;
diff --git a/jni/include/dictlist.h b/jni/include/dictlist.h
index 5fcc12f..b0eb2d0 100644
--- a/jni/include/dictlist.h
+++ b/jni/include/dictlist.h
@@ -42,9 +42,9 @@
 
   // Starting position of those words whose lengths are i+1, counted in
   // char16
-  size_t start_pos_[kMaxLemmaSize + 1];
+  uint32 start_pos_[kMaxLemmaSize + 1];
 
-  size_t start_id_[kMaxLemmaSize + 1];
+  uint32 start_id_[kMaxLemmaSize + 1];
 
   int (*cmp_func_[kMaxLemmaSize])(const void *, const void *);
 
diff --git a/jni/share/dictlist.cpp b/jni/share/dictlist.cpp
index aa7905c..b6becf1 100644
--- a/jni/share/dictlist.cpp
+++ b/jni/share/dictlist.cpp
@@ -414,14 +414,14 @@
 
   initialized_ = false;
 
-  if (fread(&scis_num_, sizeof(size_t), 1, fp) != 1)
+  if (fread(&scis_num_, sizeof(uint32), 1, fp) != 1)
     return false;
 
-  if (fread(start_pos_, sizeof(size_t), kMaxLemmaSize + 1, fp) !=
+  if (fread(start_pos_, sizeof(uint32), kMaxLemmaSize + 1, fp) !=
       kMaxLemmaSize + 1)
     return false;
 
-  if (fread(start_id_, sizeof(size_t), kMaxLemmaSize + 1, fp) !=
+  if (fread(start_id_, sizeof(uint32), kMaxLemmaSize + 1, fp) !=
       kMaxLemmaSize + 1)
     return false;
 
diff --git a/jni/share/dicttrie.cpp b/jni/share/dicttrie.cpp
index 88b819d..6255f83 100644
--- a/jni/share/dicttrie.cpp
+++ b/jni/share/dicttrie.cpp
@@ -113,16 +113,16 @@
   if (NULL == fp)
     return false;
 
-  if (fwrite(&lma_node_num_le0_, sizeof(size_t), 1, fp) != 1)
+  if (fwrite(&lma_node_num_le0_, sizeof(uint32), 1, fp) != 1)
     return false;
 
-  if (fwrite(&lma_node_num_ge1_, sizeof(size_t), 1, fp) != 1)
+  if (fwrite(&lma_node_num_ge1_, sizeof(uint32), 1, fp) != 1)
     return false;
 
-  if (fwrite(&lma_idx_buf_len_, sizeof(size_t), 1, fp) != 1)
+  if (fwrite(&lma_idx_buf_len_, sizeof(uint32), 1, fp) != 1)
     return false;
 
-  if (fwrite(&top_lmas_num_, sizeof(size_t), 1, fp) != 1)
+  if (fwrite(&top_lmas_num_, sizeof(uint32), 1, fp) != 1)
     return false;
 
   if (fwrite(root_, sizeof(LmaNodeLE0), lma_node_num_le0_, fp)
@@ -168,19 +168,18 @@
 bool DictTrie::load_dict(FILE *fp) {
   if (NULL == fp)
     return false;
-
-  if (fread(&lma_node_num_le0_, sizeof(size_t), 1, fp) != 1)
+  if (fread(&lma_node_num_le0_, sizeof(uint32), 1, fp) != 1)
     return false;
 
-  if (fread(&lma_node_num_ge1_, sizeof(size_t), 1, fp) != 1)
+  if (fread(&lma_node_num_ge1_, sizeof(uint32), 1, fp) != 1)
     return false;
 
-  if (fread(&lma_idx_buf_len_, sizeof(size_t), 1, fp) != 1)
+  if (fread(&lma_idx_buf_len_, sizeof(uint32), 1, fp) != 1)
     return false;
 
-  if (fread(&top_lmas_num_, sizeof(size_t), 1, fp) != 1 ||
-      top_lmas_num_ >= lma_idx_buf_len_)
-    return false;
+  if (fread(&top_lmas_num_, sizeof(uint32), 1, fp) != 1 ||
+     top_lmas_num_ >= lma_idx_buf_len_)
+     return false;
 
   free_resource(false);
 
diff --git a/jni/share/ngram.cpp b/jni/share/ngram.cpp
index 104b853..6aec850 100644
--- a/jni/share/ngram.cpp
+++ b/jni/share/ngram.cpp
@@ -164,7 +164,7 @@
   if (0 == idx_num_ || NULL == freq_codes_ ||  NULL == lma_freq_idx_)
     return false;
 
-  if (fwrite(&idx_num_, sizeof(size_t), 1, fp) != 1)
+  if (fwrite(&idx_num_, sizeof(uint32), 1, fp) != 1)
     return false;
 
   if (fwrite(freq_codes_, sizeof(LmaScoreType), kCodeBookSize, fp) !=
@@ -183,7 +183,7 @@
 
   initialized_ = false;
 
-  if (fread(&idx_num_, sizeof(size_t), 1, fp) != 1 )
+  if (fread(&idx_num_, sizeof(uint32), 1, fp) != 1 )
     return false;
 
   if (NULL != lma_freq_idx_)
diff --git a/jni/share/spellingtrie.cpp b/jni/share/spellingtrie.cpp
index 85be46b..57fa1f0 100644
--- a/jni/share/spellingtrie.cpp
+++ b/jni/share/spellingtrie.cpp
@@ -640,10 +640,10 @@
   if (NULL == fp || NULL == spelling_buf_)
     return false;
 
-  if (fwrite(&spelling_size_, sizeof(size_t), 1, fp) != 1)
+  if (fwrite(&spelling_size_, sizeof(uint32), 1, fp) != 1)
     return false;
 
-  if (fwrite(&spelling_num_, sizeof(size_t), 1, fp) != 1)
+  if (fwrite(&spelling_num_, sizeof(uint32), 1, fp) != 1)
     return false;
 
   if (fwrite(&score_amplifier_, sizeof(float), 1, fp) != 1)
@@ -663,10 +663,10 @@
   if (NULL == fp)
     return false;
 
-  if (fread(&spelling_size_, sizeof(size_t), 1, fp) != 1)
+  if (fread(&spelling_size_, sizeof(uint32), 1, fp) != 1)
     return false;
 
-  if (fread(&spelling_num_, sizeof(size_t), 1, fp) != 1)
+  if (fread(&spelling_num_, sizeof(uint32), 1, fp) != 1)
     return false;
 
   if (fread(&score_amplifier_, sizeof(float), 1, fp) != 1)