diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-02 20:20:47 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-02 20:20:47 +0000 |
commit | 8712f0c3591941711f8407fc069a1fbd98efbd65 (patch) | |
tree | c75825bc3d05f543e622770c684e09113ddbeb79 /include | |
parent | ad5dee8e7d01ea0cd2b96a7f46e1f6fc9692825a (diff) |
added destructor LIST::~LIST, that calls destroy() automatically.
thus manual call of destroy() might be removed from:
- class destructors;
- Unload() plugin's functions (for global data);
- local (auto) variables in functions finalizations
git-svn-id: http://svn.miranda-ng.org/main/trunk@7467 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'include')
-rw-r--r-- | include/m_system_cpp.h | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index e06e0f12df..b50449b526 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -124,35 +124,41 @@ template<class T> struct LIST sortFunc = FTSortFunc(id);
}
- __inline T* operator[](int idx) const { return (idx >= 0 && idx < count) ? items[idx] : NULL; }
- __inline int getCount(void) const { return count; }
- __inline T** getArray(void) const { return items; }
-
__inline LIST(const LIST& x)
- { items = NULL;
+ {
+ items = NULL;
List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
}
__inline LIST& operator = (const LIST& x)
- { destroy();
+ {
+ destroy();
List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
return *this;
}
+ __inline ~LIST()
+ {
+ destroy();
+ }
+
+ __inline T* operator[](int idx) const { return (idx >= 0 && idx < count) ? items[idx] : NULL; }
+ __inline int getCount(void) const { return count; }
+ __inline T** getArray(void) const { return items; }
+
__inline int getIndex(T *p) const
{ int idx;
return ( !List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx;
}
__inline void destroy(void) { List_Destroy((SortedList*)this); }
+ __inline T* find(T *p) { return (T*)List_Find((SortedList*)this, p); }
+ __inline int indexOf(T *p) { return List_IndexOf((SortedList*)this, p); }
+ __inline int insert(T *p, int idx) { return List_Insert((SortedList*)this, p, idx); }
+ __inline int remove(int idx) { return List_Remove((SortedList*)this, idx); }
- __inline T* find(T *p) { return (T*)List_Find((SortedList*)this, p); }
- __inline int indexOf(T *p) { return List_IndexOf((SortedList*)this, p); }
- __inline int insert(T *p, int idx) { return List_Insert((SortedList*)this, p, idx); }
- __inline int remove(int idx) { return List_Remove((SortedList*)this, idx); }
-
- __inline int insert(T *p) { return List_InsertPtr((SortedList*)this, p); }
- __inline int remove(T *p) { return List_RemovePtr((SortedList*)this, p); }
+ __inline int insert(T *p) { return List_InsertPtr((SortedList*)this, p); }
+ __inline int remove(T *p) { return List_RemovePtr((SortedList*)this, p); }
__inline void put(int idx, T *p) { items[idx] = p; }
|