--- rxvt-unicode/src/rxvtutil.h 2007/11/22 15:32:39 1.31 +++ rxvt-unicode/src/rxvtutil.h 2007/12/02 22:36:42 1.33 @@ -64,6 +64,25 @@ return (long(a) * long(100 - p) + long(b) * long(p) + 50) / 100; } +template +I find (I first, I last, const T& value) +{ + while (first != last && *first != value) + ++first; + + return first; +} + +// return a very temporary (and never deallocated) buffer. keep small. +void *rxvt_temp_buf (int len); + +template +static inline T * +rxvt_temp_buf (int len) +{ + return (T *)rxvt_temp_buf (len * sizeof (T)); +} + // some bit functions, xft fuck me plenty #if HAVE_GCC_BUILTINS static inline int ctz (unsigned int x) { return __builtin_ctz (x); } @@ -347,7 +366,15 @@ struct vector : simplevec { }; -#if 0 +struct stringvec : simplevec +{ + ~stringvec () + { + for (char **c = begin (); c != end (); c++) + free (*c); + } +}; + template struct rxvt_vec : simplevec { typedef T *iterator; @@ -361,16 +388,6 @@ T &operator [] (int i) { return * (T *) (& ((* (simplevec *)this)[i])); } const T &operator [] (int i) const { return * (const T *) (& ((* (const simplevec *)this)[i])); } }; -#endif - -template -I find (I first, I last, const T& value) -{ - while (first != last && *first != value) - ++first; - - return first; -} template struct auto_ptr { @@ -432,24 +449,5 @@ typedef auto_ptr auto_str; -struct stringvec : simplevec -{ - ~stringvec () - { - for (char **c = begin (); c != end (); c++) - free (*c); - } -}; - -// return a very temporary (and never deallocated) buffer. keep small. -void *rxvt_temp_buf (int len); - -template -static inline T * -rxvt_temp_buf (int len) -{ - return (T *)rxvt_temp_buf (len * sizeof (T)); -} - #endif