--- rxvt-unicode/src/rxvtutil.h 2006/01/02 15:35:43 1.15 +++ rxvt-unicode/src/rxvtutil.h 2006/01/22 00:36:59 1.19 @@ -1,6 +1,7 @@ #ifndef RXVT_UTIL_H #define RXVT_UTIL_H +#include #include #define PP_CONCAT_(a, b) a ## b @@ -19,6 +20,7 @@ static bool vax () { return e == 0x44332211; }; } byteorder; +// various utility functions template static inline T min (T a, U b) { return a < (T)b ? a : (T)b; } template static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } template static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } @@ -37,6 +39,7 @@ #define IN_RANGE_EXC(val,beg,end) \ ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) +// makes dynamically allocated objects zero-initialised struct zero_initialized { void *operator new (size_t s); void operator delete (void *p, size_t s); @@ -256,14 +259,14 @@ void erase (iterator first, iterator last) { if (last != first) { - memmove (first, last, (end ()-last)*sizeof (T)); + memmove (first, last, (end () - last) * sizeof (T)); _last -= last - first; } } void erase (iterator pos) { if (pos != end ()) { - memmove (pos, pos+1, (end ()- (pos+1))*sizeof (T)); + memmove (pos, pos+1, (end () - (pos+1)) * sizeof (T)); --_last; } } @@ -391,7 +394,7 @@ ~stringvec () { for (char **c = begin (); c != end (); c++) - delete [] *c; + free (*c); } };