diff options
author | Kai-Wei Chang <kchang10.uiuc@gmail.com> | 2014-12-07 02:53:24 +0300 |
---|---|---|
committer | Kai-Wei Chang <kchang10.uiuc@gmail.com> | 2014-12-07 02:53:24 +0300 |
commit | e892011be152ac3bf730da1378a7eb7a95bbb8b7 (patch) | |
tree | 84a60c5af38610107eab9b0a08e920823dc8685d /vowpalwabbit | |
parent | b88e9ad91c74bdde6dad059d892849178b6f7b03 (diff) |
Entity-relation memory leak fix
Diffstat (limited to 'vowpalwabbit')
-rw-r--r-- | vowpalwabbit/search_entityrelationtask.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/vowpalwabbit/search_entityrelationtask.cc b/vowpalwabbit/search_entityrelationtask.cc index a5360260..b4c8729b 100644 --- a/vowpalwabbit/search_entityrelationtask.cc +++ b/vowpalwabbit/search_entityrelationtask.cc @@ -116,13 +116,12 @@ namespace EntityRelationTask { } id1 = atoi(s1.c_str()); idx++; - if(type == 'R'){ - while(idx < tag.size() && tag[idx] != '_' && tag[idx] != '\0'){ - s2.push_back(tag[idx]); - idx++; - } - id2 = atoi(s2.c_str()); + assert(type == 'R'); + while(idx < tag.size() && tag[idx] != '_' && tag[idx] != '\0'){ + s2.push_back(tag[idx]); + idx++; } + id2 = atoi(s2.c_str()); } size_t predict_entity(Search::search&sch, example* ex, v_array<size_t>& predictions, ptag my_tag, bool isLdf=false){ @@ -245,13 +244,13 @@ namespace EntityRelationTask { size_t count = 0; for (size_t i=0; i<n_ent; i++) { if(count ==t){ - predictions[i] = predict_entity(sch, ec[i], predictions, i); + predictions[i] = predict_entity(sch, ec[i], predictions, (ptag)i); break; } count++; for(size_t j=0; j<i; j++) { if(count ==t){ - uint32_t rel_index = n_ent + (2*n_ent-j-1)*j/2 + i-j-1; + uint32_t rel_index = (uint32_t) (n_ent + (2*n_ent-j-1)*j/2 + i-j-1); predictions[rel_index] = predict_relation(sch, ec[rel_index], predictions, rel_index); break; } @@ -273,7 +272,7 @@ namespace EntityRelationTask { // loop until all the entity and relation types are predicted for(size_t t=0; ; t++){ - uint32_t i = t % ec.size(); + uint32_t i = (uint32_t) t % ec.size(); if(n_predicts == ec.size()) break; |