From b0a7d86fbd39a1b7a648f0a72db1f6daf058e540 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 29 Dec 2015 13:40:50 +0000 Subject: [PATCH] redo using allocator --- contrib/other-builds/moses2/Search/CubePruning/Stack.cpp | 9 ++++----- contrib/other-builds/moses2/Search/CubePruning/Stack.h | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/contrib/other-builds/moses2/Search/CubePruning/Stack.cpp b/contrib/other-builds/moses2/Search/CubePruning/Stack.cpp index 237051537..b8a2c75f5 100644 --- a/contrib/other-builds/moses2/Search/CubePruning/Stack.cpp +++ b/contrib/other-builds/moses2/Search/CubePruning/Stack.cpp @@ -82,15 +82,14 @@ void MiniStack::SortAndPruneHypos(const Manager &mgr) const /////////////////////////////////////////////////////////////// Stack::Stack(const Manager &mgr) { - //MemPool &pool = mgr.GetPool(); + MemPool &pool = mgr.GetPool(); //cerr << "Coll=" << sizeof(Coll) << endl; - //alloc = new MemPoolAllocator< std::pair > (mgr.GetPool()); - m_coll = new Coll(); -} + alloc = new MemPoolAllocator< std::pair > (pool); + m_coll = new (pool.Allocate()) Coll(*alloc);} Stack::~Stack() { - delete m_coll; + delete alloc; } void Stack::Add(const Hypothesis *hypo, Recycler &hypoRecycle) diff --git a/contrib/other-builds/moses2/Search/CubePruning/Stack.h b/contrib/other-builds/moses2/Search/CubePruning/Stack.h index 8286805bc..cb08a77c1 100644 --- a/contrib/other-builds/moses2/Search/CubePruning/Stack.h +++ b/contrib/other-builds/moses2/Search/CubePruning/Stack.h @@ -62,8 +62,8 @@ public: typedef boost::unordered_map, - std::equal_to - // MemPoolAllocator< std::pair > + std::equal_to, + MemPoolAllocator< std::pair > > Coll; @@ -84,7 +84,7 @@ public: } protected: - //MemPoolAllocator< std::pair > *alloc; + MemPoolAllocator< std::pair > *alloc; Coll *m_coll; StackAdd Add(const Hypothesis *hypo);