From: Vadim Zeitlin Date: Tue, 29 Dec 1998 16:54:48 +0000 (+0000) Subject: added WX_CLEAR_ARRAY() macro to delete all the elements of an array X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/2b9bd418c5ca5cfabf1d183db391893d1040b5f2?ds=inline added WX_CLEAR_ARRAY() macro to delete all the elements of an array git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1279 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index 67bcab55d8..7b090023b2 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -411,5 +411,23 @@ WX_DEFINE_ARRAY(void *, wxArrayPtrVoid); #undef WXDLLEXPORTLOCAL #define WXDLLEXPORTLOCAL +// ----------------------------------------------------------------------------- +// convinience macros +// ----------------------------------------------------------------------------- + +// delete all array elements +// +// NB: the class declaration of the array elements must be visible from the +// place where you use this macro, otherwise the proper destructor may not +// be called (a decent compiler should give a warning about it, but don't +// count on it)! +#define WX_CLEAR_ARRAY(array) \ + { \ + size_t count = array.Count(); \ + for ( size_t n = 0; n < count; n++ ) \ + { \ + delete array[n]; \ + } \ + } #endif // _DYNARRAY_H