summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/Main.h4
-rw-r--r--lib/Image.cc4
-rw-r--r--lib/Main.cc13
3 files changed, 8 insertions, 13 deletions
diff --git a/include/Main.h b/include/Main.h
index 4a81b3e..cbc6dea 100644
--- a/include/Main.h
+++ b/include/Main.h
@@ -9,6 +9,8 @@ class Main : public Base {
virtual ~Main();
virtual int startup() throw (GeneralException) = 0;
protected:
+ static int truemain(Main *, int, char **, char **);
+ private:
void set_args(int, char **, char **);
int argc;
char ** argv;
@@ -19,6 +21,6 @@ class Main : public Base {
};
#define CODE_BEGINS class Appli : public Main {
-#define CODE_ENDS } * Application = new Appli();
+#define CODE_ENDS }; int main(int argc, char ** argv, char ** enve) { return Main::truemain(&Appli(), argc, argv, enve); }
#endif
diff --git a/lib/Image.cc b/lib/Image.cc
index 2e33da7..a0ece1b 100644
--- a/lib/Image.cc
+++ b/lib/Image.cc
@@ -9,9 +9,7 @@ Image::Image(unsigned int ax, unsigned int ay) : x(ax), y(ay), img((Color *) mal
}
Image::~Image() {
- char * t = (char *) img;
- free(t);
- img = 0;
+ free((char *&) img);
}
bool Image::CanWrite() const {
diff --git a/lib/Main.cc b/lib/Main.cc
index 653adea..5571689 100644
--- a/lib/Main.cc
+++ b/lib/Main.cc
@@ -8,8 +8,6 @@ Main::Main() : setted(false) {}
Main::~Main() {}
-extern Main * Application;
-
void Main::set_args(int a_argc, char ** a_argv, char ** a_enve) {
if (setted) {
return;
@@ -20,7 +18,7 @@ void Main::set_args(int a_argc, char ** a_argv, char ** a_enve) {
setted = true;
}
-int main(int argc, char ** argv, char ** enve) {
+int Main::truemain(Main * Application, int argc, char ** argv, char ** enve) {
int r;
try {
@@ -32,14 +30,11 @@ int main(int argc, char ** argv, char ** enve) {
}
catch (GeneralException e) {
Base::printm(M_ERROR, "The application caused an exception: %s\n", e.GetMsg());
- delete Application;
- exit(-1);
+ return -1;
}
catch (...) {
Base::printm(M_ERROR, "The application caused an unknow exception\n");
- delete Application;
- exit(-1);
+ return -1;
}
- delete Application;
- exit(r);
+ return r;
}