Skip to content

Commit

Permalink
added init method to fix uninitialsed memory bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnapf committed Jul 18, 2013
1 parent e542d2b commit 15b307a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/shogun/ui/GUIPluginEstimate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,32 @@

using namespace shogun;

CGUIPluginEstimate::CGUIPluginEstimate() : CSGObject()
{
init();
}

CGUIPluginEstimate::CGUIPluginEstimate(CSGInterface* ui_)
: CSGObject(), ui(ui_), estimator(NULL),
pos_pseudo(1e-10), neg_pseudo(1e-10)
: CSGObject()
{
init();

ui=ui_;
}

CGUIPluginEstimate::~CGUIPluginEstimate()
{
SG_UNREF(estimator);
}

void CGUIPluginEstimate::init()
{
ui=NULL;
estimator=NULL;
pos_pseudo=1e-10;
neg_pseudo=1e-10;
}

bool CGUIPluginEstimate::new_estimator(float64_t pos, float64_t neg)
{
SG_UNREF(estimator);
Expand Down
5 changes: 4 additions & 1 deletion src/shogun/ui/GUIPluginEstimate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CGUIPluginEstimate : public CSGObject

public:
/** constructor */
CGUIPluginEstimate() {};
CGUIPluginEstimate();
/** constructor
* @param interface
*/
Expand Down Expand Up @@ -65,6 +65,9 @@ class CGUIPluginEstimate : public CSGObject
/** @return object name */
virtual const char* get_name() const { return "GUIPluginEstimate"; }

private:
void init();

protected:
/** ui */
CSGInterface* ui;
Expand Down

0 comments on commit 15b307a

Please sign in to comment.