Kaydet (Commit) e05a6419 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Caolán McNamara

fix memory leaks caused with SmNodeStack

SmNodeStack now frees its own pointers after use.

Change-Id: Ie43eb887810a3424109708c956ccbdf97fc5a2e5
Reviewed-on: https://gerrit.libreoffice.org/12970Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 924b378a
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
#include <vector> #include <vector>
#include <ostream> #include <ostream>
#include <stdio.h> #include <stdio.h>
#include <stack>
#include "types.hxx" #include "types.hxx"
#include "token.hxx" #include "token.hxx"
#include "error.hxx" #include "error.hxx"
#include "rect.hxx" #include "rect.hxx"
#include "format.hxx" #include "format.hxx"
#include <boost/ptr_container/ptr_deque.hpp>
#define ATTR_BOLD 0x0001 #define ATTR_BOLD 0x0001
...@@ -60,18 +60,17 @@ class SmNode; ...@@ -60,18 +60,17 @@ class SmNode;
class SmStructureNode; class SmStructureNode;
typedef boost::shared_ptr<SmNode> SmNodePointer; typedef boost::shared_ptr<SmNode> SmNodePointer;
typedef std::stack< SmNode* > SmNodeStack; typedef boost::ptr_deque<SmNode> SmNodeStack;
typedef std::vector< SmNode * > SmNodeArray; typedef std::vector< SmNode * > SmNodeArray;
typedef std::vector< SmStructureNode * > SmStructureNodeArray; typedef std::vector< SmStructureNode * > SmStructureNodeArray;
template < typename T > template < typename T >
T* popOrZero( ::std::stack<T*> & rStack ) T* popOrZero( boost::ptr_deque<T> & rStack )
{ {
if (rStack.empty()) if (rStack.empty())
return 0; return 0;
T* pTmp = rStack.top(); auto pTmp = rStack.pop_front();
rStack.pop(); return pTmp.release();
return pTmp;
} }
enum SmScaleMode { SCALE_NONE, SCALE_WIDTH, SCALE_HEIGHT }; enum SmScaleMode { SCALE_NONE, SCALE_WIDTH, SCALE_HEIGHT };
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment