+ typedef T CharType;
+
+ wxCharTypeBuffer(const CharType *str = NULL)
+ : m_str(str ? wxStrDup(str) : NULL)
+ {
+ }
+
+ wxCharTypeBuffer(size_t len)
+ : m_str((CharType *)malloc((len + 1)*sizeof(CharType)))
+ {
+ m_str[len] = (CharType)0;
+ }
+
+ /* no need to check for NULL, free() does it */
+ ~wxCharTypeBuffer() { free(m_str); }
+
+ /*
+ WARNING:
+
+ the copy ctor and assignment operators change the passed in object
+ even although it is declared as "const", so:
+
+ a) it shouldn't be really const
+ b) you shouldn't use it afterwards (or know that it was reset)
+
+ This is very ugly but is unfortunately needed to make the normal use\
+ of wxCharTypeBuffer buffer objects possible and is very similar to what
+ std::auto_ptr<> does (as if it were an excuse...)
+ */
+
+ /*
+ because of the remark above, release() is declared const even if it
+ isn't really const
+ */
+ CharType *release() const
+ {
+ CharType *p = m_str;
+ ((wxCharTypeBuffer *)this)->m_str = NULL;
+ return p;
+ }
+
+ void reset()
+ {
+ free(m_str);
+ m_str = NULL;
+ }
+
+ wxCharTypeBuffer(const wxCharTypeBuffer& src)
+ : m_str(src.release())
+ {
+ }
+
+ wxCharTypeBuffer& operator=(const CharType *str)
+ {
+ free(m_str);
+ m_str = str ? wxStrDup(str) : NULL;
+ return *this;
+ }
+
+ wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src)