summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-11-27 22:08:23 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-11-27 22:08:23 +0000
commit6b301d4365a2928c9e634eceb764f93bbec5ab6d (patch)
tree5c8ab6571d5e54e08f0d6d07b204fd648c7accc1
parente36e07f3131ff94a8faa7e2a076a79ba7288320d (diff)
Fixed memory leaks in Fluid - Thanks for the patch (STR 2455)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7900 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--fluid/Fl_Type.h26
-rw-r--r--fluid/Fl_Widget_Type.cxx11
-rw-r--r--fluid/Fl_Widget_Type.h2
3 files changed, 36 insertions, 3 deletions
diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h
index eb93e616c..69690d872 100644
--- a/fluid/Fl_Type.h
+++ b/fluid/Fl_Type.h
@@ -166,6 +166,13 @@ class Fl_Function_Type : public Fl_Type {
const char* return_type;
char public_, cdecl_, constructor, havewidgets;
public:
+ Fl_Function_Type() :
+ Fl_Type(),
+ return_type(0L), public_(0), cdecl_(0), constructor(0), havewidgets(0)
+ { }
+ ~Fl_Function_Type() {
+ if (return_type) free((void*)return_type);
+ }
Fl_Type *make();
void write_code1();
void write_code2();
@@ -199,6 +206,10 @@ public:
class Fl_CodeBlock_Type : public Fl_Type {
const char* after;
public:
+ Fl_CodeBlock_Type() : Fl_Type(), after(0L) { }
+ ~Fl_CodeBlock_Type() {
+ if (after) free((void*)after);
+ }
Fl_Type *make();
void write_code1();
void write_code2();
@@ -229,8 +240,12 @@ public:
};
class Fl_Data_Type : public Fl_Decl_Type {
- const char *filename_;
+ const char *filename_;
public:
+ Fl_Data_Type() : Fl_Decl_Type(), filename_(0L) { }
+ ~Fl_Data_Type() {
+ if (filename_) free((void*)filename_);
+ }
Fl_Type *make();
void write_code1();
void write_code2();
@@ -245,6 +260,10 @@ class Fl_DeclBlock_Type : public Fl_Type {
const char* after;
char public_;
public:
+ Fl_DeclBlock_Type() : Fl_Type(), after(0L) { }
+ ~Fl_DeclBlock_Type() {
+ if (after) free((void*)after);
+ }
Fl_Type *make();
void write_code1();
void write_code2();
@@ -279,6 +298,11 @@ class Fl_Class_Type : public Fl_Type {
const char* subclass_of;
char public_;
public:
+ Fl_Class_Type() : Fl_Type(), subclass_of(0L) { }
+ ~Fl_Class_Type() {
+ if (subclass_of) free((void*)subclass_of);
+ }
+
// state variables for output:
char write_public_state; // true when public: has been printed
Fl_Class_Type* parent_class; // save class if nested
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index 2f6f3328c..48897f7fe 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -198,7 +198,8 @@ void Fl_Widget_Type::setlabel(const char *n) {
}
Fl_Widget_Type::Fl_Widget_Type() {
- for (int n=0; n<NUM_EXTRA_CODE; n++) {extra_code_[n] = 0; subclass_ = 0;}
+ for (int n=0; n<NUM_EXTRA_CODE; n++) {extra_code_[n] = 0; }
+ subclass_ = 0;
hotspot_ = 0;
tooltip_ = 0;
image_name_ = 0;
@@ -216,6 +217,13 @@ Fl_Widget_Type::~Fl_Widget_Type() {
if (o->parent()) ((Fl_Group*)o->parent())->remove(*o);
delete o;
}
+ if (subclass_) free((void*)subclass_);
+ if (tooltip_) free((void*)tooltip_);
+ if (image_name_) free((void*)image_name_);
+ if (inactive_name_) free((void*)inactive_name_);
+ for (int n=0; n<NUM_EXTRA_CODE; n++) {
+ if (extra_code_[n]) free((void*) extra_code_[n]);
+ }
}
void Fl_Widget_Type::extra_code(int m,const char *n) {
@@ -291,6 +299,7 @@ static Fl_Window *the_panel;
// initialized parts of the widget that are nyi by fluid.
Fl_Widget_Type *current_widget; // one of the selected ones
+void* const LOAD = (void *)"LOAD"; // "magic" pointer to indicate that we need to load values into the dialog
static int numselected; // number selected
static int haderror;
diff --git a/fluid/Fl_Widget_Type.h b/fluid/Fl_Widget_Type.h
index 66eeddc17..ded65283c 100644
--- a/fluid/Fl_Widget_Type.h
+++ b/fluid/Fl_Widget_Type.h
@@ -34,7 +34,7 @@
struct Fl_Menu_Item;
class Fluid_Image;
-void* const LOAD = (void *)9831;
+extern void* const LOAD;
extern Fl_Widget_Type *current_widget; // one of the selected ones
//