--- rxvt-unicode/src/rxvtutil.h 2012/05/25 07:48:03 1.55 +++ rxvt-unicode/src/rxvtutil.h 2021/05/13 19:40:20 1.65 @@ -1,20 +1,15 @@ #ifndef RXVT_UTIL_H #define RXVT_UTIL_H -#include #include #include + +#define ECB_NO_THREADS 1 #include "ecb.h" + #include "estl.h" -// increases code size unless -fno-enforce-eh-specs -#if __GNUC__ -# define NOTHROW -# define THROW(x) -#else -# define NOTHROW throw() -# define THROW(x) throw x -#endif +#include "emman.h" // various utility functions template static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } @@ -23,8 +18,6 @@ template static inline T clamp (T v, U a, V b) { return v < (T)a ? a : v >(T)b ? b : v; } template static inline void clamp_it (T &v, U a, V b) { v = v < (T)a ? a : v >(T)b ? b : v; } -template static inline T squared_diff (T a, T b) { return (a - b) * (a - b); } - // linear interpolation template static inline T @@ -87,82 +80,7 @@ }; #endif -inline void * -operator new (size_t size) -{ - // TODO: use rxvt_malloc - return malloc (size); -} - -inline void -operator delete (void *p) -{ - free (p); -} - -template -struct auto_ptr -{ - T *p; - - auto_ptr () : p (0) { } - - explicit - auto_ptr (T *a) : p (a) { } - - auto_ptr (auto_ptr &a) - { - p = a.p; - a.p = 0; - } - - template - auto_ptr (auto_ptr &a) - { - p = a.p; - a.p = 0; - } - - ~auto_ptr () - { - delete p; - } - - void reset (T *a) - { - delete p; - p = a; - } - - // void because it makes sense in our context - void operator =(auto_ptr &a) - { - *this = a.p; - a.p = 0; - } - - template - void operator =(auto_ptr &a) - { - *this = a.p; - a.p = 0; - } - - T *operator ->() const { return p; } - T &operator *() const { return *p; } - - operator T *() { return p; } - T *get () const { return p; } - - T *release() - { - T *r = p; - p = 0; - return r; - } -}; - -typedef auto_ptr auto_str; +typedef estl::scoped_array auto_str; #endif