1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: auto buffer classes: buffers which automatically free memory
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 // these classes are for private use only for now, they're not documented
17 #include <string.h> // strdup()
18 #include <wchar.h> // wcsdup()
20 // ----------------------------------------------------------------------------
21 // Special classes for (wide) character strings: they use malloc/free instead
23 // ----------------------------------------------------------------------------
28 wxCharBuffer(const char *str
)
30 wxASSERT_MSG( str
, "NULL string in wxCharBuffer" );
32 m_str
= str ?
strdup(str
) : (char *)NULL
;
35 // no need to check for NULL, free() does it
36 ~wxCharBuffer() { free(m_str
); }
38 operator const char *() const { return m_str
; }
47 wxWCharBuffer(const wchar_t *wcs
)
49 wxASSERT_MSG( wcs
, "NULL string in wxWCharBuffer" );
51 m_wcs
= wcs ?
wcsdup(wcs
) : (wchar_t *)NULL
;
54 // no need to check for NULL, free() does it
55 ~wxWCharBuffer() { free(m_wcs
); }
57 operator const wchar_t *() const { return m_wcs
; }
63 // ----------------------------------------------------------------------------
64 // template class for any kind of data
65 // ----------------------------------------------------------------------------
69 #endif // _WX_BUFFER_H