Update of /cvsroot/mahogany/M/include
In directory sc8-pr-cvs1:/tmp/cvs-serv4520/include
Modified Files:
ViewFilter.h miscutil.h strutil.h
Log Message:
Fixed harmless memory allocation bugs
Index: ViewFilter.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/ViewFilter.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -b -u -2 -r1.7 -r1.8
--- ViewFilter.h 1 Oct 2003 22:04:11 -0000 1.7
+++ ViewFilter.h 2 Oct 2003 09:49:38 -0000 1.8
@@ -20,4 +20,5 @@
class MessageViewer;
class MTextStyle;
+class Profile;
// the viewer filter module interface name
Index: miscutil.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/miscutil.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -b -u -2 -r1.18 -r1.19
--- miscutil.h 18 Sep 2003 16:30:43 -0000 1.18
+++ miscutil.h 2 Oct 2003 09:49:38 -0000 1.19
@@ -44,4 +44,76 @@
const String& defaultName);
+class BoundArrayCommon
+{
+public:
+ BoundArrayCommon() : m_size(0) {}
+
+ size_t Size() const { return m_size; }
+
+protected:
+ size_t m_size;
+};
+
+#define BOUND_ARRAY(type,name) \
+ class name : public BoundArrayCommon \
+ { \
+ public: \
+ typedef type HostType; \
+ \
+ name() : m_array(NULL) {} \
+ ~name() { Destroy(); } \
+ \
+ void Initialize(size_t count); \
+ type *Get() { return m_array; } \
+ type& At(size_t offset); \
+ type& operator[](size_t offset) { return At(offset); } \
+ \
+ private: \
+ void Destroy(); \
+ \
+ type *m_array; \
+ }
+
+#define IMPLEMENT_BOUND_ARRAY(name) \
+ void name::Destroy() { delete[] m_array; } \
+ \
+ void name::Initialize(size_t count) \
+ { \
+ ASSERT( !m_array ); \
+ m_array = new name::HostType[m_size = count]; \
+ } \
+ \
+ name::HostType& name::At(size_t offset) \
+ { \
+ ASSERT( offset < m_size ); \
+ return m_array[offset]; \
+ } \
+
+#define BOUND_POINTER(type,name) \
+ class name \
+ { \
+ public: \
+ typedef type HostType; \
+ \
+ name() : m_pointer(NULL) {} \
+ ~name() { Destroy(); } \
+ \
+ void Initialize(); \
+ type *operator->() { return m_pointer; } \
+ \
+ private: \
+ void Destroy(); \
+ \
+ type *m_pointer; \
+ }
+
+#define IMPLEMENT_BOUND_POINTER(name) \
+ void name::Destroy() { delete m_pointer; } \
+ \
+ void name::Initialize() \
+ { \
+ ASSERT( !m_pointer ); \
+ m_pointer = new name::HostType; \
+ } \
//@}
Index: strutil.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/strutil.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -b -u -2 -r1.63 -r1.64
--- strutil.h 26 Sep 2003 15:10:37 -0000 1.63
+++ strutil.h 2 Oct 2003 09:49:38 -0000 1.64
@@ -13,4 +13,5 @@
#ifndef USE_PCH
+# include "miscutil.h"
#endif
@@ -366,5 +367,5 @@
public:
DetectSignature();
- ~DetectSignature();
+
bool Initialize(Profile *profile);
bool StartsHere(const wxChar *cptr);
@@ -374,5 +375,6 @@
bool m_useRE;
// a RE to detect the start of the signature
- wxRegEx *m_reSig;
+ BOUND_POINTER(wxRegEx,RegExPointer);
+ RegExPointer m_reSig;
#endif
};
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates