diff options
-rw-r--r-- | include/Exceptions.h | 13 | ||||
-rw-r--r-- | lib/Exceptions.cc | 28 | ||||
-rw-r--r-- | lib/Image.cc | 2 | ||||
-rw-r--r-- | lib/TaskMan.cc | 2 |
4 files changed, 11 insertions, 34 deletions
diff --git a/include/Exceptions.h b/include/Exceptions.h index 8dd473f..489a761 100644 --- a/include/Exceptions.h +++ b/include/Exceptions.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: Exceptions.h,v 1.33 2003-12-04 04:09:02 pixel Exp $ */ +/* $Id: Exceptions.h,v 1.34 2003-12-22 01:57:01 pixel Exp $ */ #ifndef __EXCEPTIONS_H__ #define __EXCEPTIONS_H__ @@ -50,9 +50,12 @@ class Base { void * operator new(size_t s); void * operator new(size_t s, void * p); void operator delete(void * p); - static void free(void *& p); - static void free(char *& p); - static void free(unsigned char *& p); + template <class T> + static void free(T *& p) { + unsigned char * t = (unsigned char *) p; + xfree(t); + p = 0; + } static int pipe(int * p, int flag = 0); static pid_t fork(); static void exit(int); @@ -81,8 +84,6 @@ class GeneralException : public Base { char * xstrdup(const char *); void * xmalloc(size_t) throw (GeneralException); -void xfree(void *&); -void xfree(char *&); void xfree(unsigned char *&); void * xrealloc(void *, size_t); int xpipe(int *, int = 0) throw (GeneralException); diff --git a/lib/Exceptions.cc b/lib/Exceptions.cc index 0d09870..caa0257 100644 --- a/lib/Exceptions.cc +++ b/lib/Exceptions.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: Exceptions.cc,v 1.30 2003-12-04 04:09:02 pixel Exp $ */ +/* $Id: Exceptions.cc,v 1.31 2003-12-22 01:57:02 pixel Exp $ */ #include <malloc.h> #include <string.h> @@ -142,18 +142,6 @@ void * xrealloc(void * ptr, size_t s) { } void xfree(unsigned char *& p) { - char * t = (char *) p; - xfree(t); - p = 0; -} - -void xfree(void *& p) { - char * t = (char *) p; - xfree(t); - p = 0; -} - -void xfree(char *& p) { #ifdef DEBUG // Base::printm(M_BARE, String(_("Freeing pointer at %p\n")), p); #endif @@ -237,19 +225,7 @@ void Base::operator delete(void * p) { #ifdef DEBUG printm(M_BARE, _("Operator delete(p) called. Freeing memory.\n")); #endif - xfree(p); -} - -void Base::free(void *& p) { - xfree(p); -} - -void Base::free(char *& p) { - xfree(p); -} - -void Base::free(unsigned char *& p) { - xfree(p); + free(p); } int Base::pipe(int * p, int flag) { diff --git a/lib/Image.cc b/lib/Image.cc index 6b698ae..d098de3 100644 --- a/lib/Image.cc +++ b/lib/Image.cc @@ -9,7 +9,7 @@ Image::Image(unsigned int ax, unsigned int ay) : x(ax), y(ay), img((Color *) mal } Image::~Image() { - free((char *&) img); + free(img); } bool Image::CanWrite() const { diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc index c1c60ae..cc24c80 100644 --- a/lib/TaskMan.cc +++ b/lib/TaskMan.cc @@ -387,7 +387,7 @@ void TaskMan::MainLoop() throw (GeneralException) { } } } - free((void *) ufsd); + free(ufsd); } /* And finally, let's clean-up all the zombies around here. */ |