From f1558e4afd2afe5b23c4ecf9fb4de0415068cc02 Mon Sep 17 00:00:00 2001 From: graehl Date: Tue, 31 Aug 2010 02:16:48 +0000 Subject: l2r bugfixes git-svn-id: https://ws10smt.googlecode.com/svn/trunk@636 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/apply_fsa_models.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'decoder/apply_fsa_models.cc') diff --git a/decoder/apply_fsa_models.cc b/decoder/apply_fsa_models.cc index 83083fc5..4bf4e031 100755 --- a/decoder/apply_fsa_models.cc +++ b/decoder/apply_fsa_models.cc @@ -21,6 +21,8 @@ #include "show.h" #include "string_to.h" +#define SAFE_VALGRIND 1 + #define DFSA(x) x //fsa earley chart @@ -494,9 +496,23 @@ struct Item; typedef Item *ItemP; /* we use a single type of item so it can live in a single best-first queue. we hold them by pointer so they can have mutable state, e.g. priority/location, but also lists of predictions and kbest completions (i.e. completions[L,r] = L -> * (r,s), by 1best for each possible s. we may discover more s later. we could use different subtypes since we hold by pointer, but for now everything will be packed as variants of Item */ +#undef INIT_LOCATION +#if D_ARY_TRACK_OUT_OF_HEAP +# define INIT_LOCATION , location(D_ARY_HEAP_NULL_INDEX) +#elsif !defined(NDEBUG) || SAFE_VALGRIND + // avoid spurious valgrind warning +# define INIT_LOCATION , location() +#else +# define INIT_LOCATION +#endif + struct Item : ItemPrio,ItemKey { - explicit Item(NodeP dot,int next=0) : ItemKey(dot),next(next),from(0),location(D_ARY_HEAP_NULL_INDEX) { } - explicit Item(NodeP dot,FFState const& state,int next=0) : ItemKey(dot,state),next(next),from(0),location(D_ARY_HEAP_NULL_INDEX) { } + explicit Item(NodeP dot,int next=0) : ItemKey(dot),next(next),from(0) + INIT_LOCATION + { } + explicit Item(NodeP dot,FFState const& state,int next=0) : ItemKey(dot,state),next(next),from(0) + INIT_LOCATION + { } typedef std::queue Predicted; Predicted predicted; // this is empty, unless this is a predicted L -> .asdf item, or a to-complete L -> asdf . int next; // index of dot->adj to complete (if dest==0), or predict (if NT), or scan (if word). note: we could store pointer inside adj since it and trie are @ fixed addrs. less pointer arith, more space. -- cgit v1.2.3