diff options
author | Pixel <Pixel> | 2001-10-29 15:44:12 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2001-10-29 15:44:12 +0000 |
commit | 2e5bed84841f33ff28dd95b77b555720c875a286 (patch) | |
tree | de6cbcbf5fa65e90e1888d52a9426373a1638c61 /include/Exceptions.h | |
parent | 0a6190d0269392e875a479df01b152d47ea4143c (diff) |
Beginning task manager
Diffstat (limited to 'include/Exceptions.h')
-rw-r--r-- | include/Exceptions.h | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/include/Exceptions.h b/include/Exceptions.h index 6e8e1db..16737e0 100644 --- a/include/Exceptions.h +++ b/include/Exceptions.h @@ -25,7 +25,17 @@ // Impossible de surcharger free(void *). Les compilateurs // refuseront de passer un char * par exemple. +#ifdef OVER_FREE #define free(p) xfree((void*)p) +#else +#include <stdlib.h> +#endif + +class MemoryException; + +char * xstrdup(const char *) throw (MemoryException); +void * xmalloc(ssize_t) throw (MemoryException); +void xfree(void *&); // On prédéfinit la classe String, pour éviter // les deadlocks de compilation... @@ -33,13 +43,27 @@ class String; class Base { public: - char * strdup(const char *) const; - void * malloc(ssize_t) const; - void * operator new(size_t); - void * operator new(size_t, void *); + char * strdup(const char * s) const { + return xstrdup(s); + } + void * malloc(ssize_t s) const { + return malloc(s); + } + void * operator new(size_t s) { + return xmalloc(s); + } + void * operator new(size_t s, void * p) { + return memset(p, 0, s); + } + void free(void * p) const { + xfree(p); + } + void free(char * p) const { + xfree((void *) p); + } }; -class GeneralException : public Base{ +class GeneralException : public Base { public: GeneralException(String); GeneralException(const GeneralException &); @@ -76,10 +100,6 @@ class IOInternal : public GeneralException { IOInternal(String, op_t); }; -char * xstrdup(const char *) throw (MemoryException); -void * xmalloc(ssize_t) throw (MemoryException); -void xfree(void *&); - #else #error This only works with a C++ compiler #endif |