author | erik <erik> | 2007-01-19 01:12:38 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-19 01:12:38 (UTC) |
commit | 1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7 (patch) (unidiff) | |
tree | af4a12bc46e25853386dc53868b869e1bf05d863 /noncore/apps/opie-reader/Bkmks.h | |
parent | 2b45dc71e79a3eb7d4e8553273c9bc4f4282d50a (diff) | |
download | opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.zip opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.tar.gz opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.tar.bz2 |
Every single file in this commit had a memory leak where a resource is
allocated in the constructor but not de-allocated in the destructor.
This commit fixes that.
Diffstat (limited to 'noncore/apps/opie-reader/Bkmks.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.h | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.h b/noncore/apps/opie-reader/Bkmks.h index c2275e2..985e158 100644 --- a/noncore/apps/opie-reader/Bkmks.h +++ b/noncore/apps/opie-reader/Bkmks.h | |||
@@ -1,79 +1,76 @@ | |||
1 | #ifndef __Bkmks_h | 1 | #ifndef __Bkmks_h |
2 | #define __Bkmks_h | 2 | #define __Bkmks_h |
3 | 3 | ||
4 | #include "config.h" | 4 | #include "config.h" |
5 | #include "Filedata.h" | 5 | #include "Filedata.h" |
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | 7 | ||
8 | template<class T> | 8 | template<class T> |
9 | class CList; | 9 | class CList; |
10 | 10 | ||
11 | class Bkmk | 11 | class Bkmk |
12 | { | 12 | { |
13 | friend class BkmkFile; | 13 | friend class BkmkFile; |
14 | unsigned char* m_name; | 14 | unsigned char* m_name; |
15 | unsigned short m_namelen; | 15 | unsigned short m_namelen; |
16 | unsigned char* m_anno; | 16 | unsigned char* m_anno; |
17 | unsigned short m_annolen; | 17 | unsigned short m_annolen; |
18 | unsigned int m_position; | 18 | unsigned int m_position; |
19 | unsigned int m_position2; | 19 | unsigned int m_position2; |
20 | unsigned char m_red,m_green,m_blue, m_level; | 20 | unsigned char m_red,m_green,m_blue, m_level; |
21 | void init(const void*, unsigned short, const void*, unsigned short, unsigned int); | 21 | void init(const void*, unsigned short, const void*, unsigned short, unsigned int); |
22 | public: | 22 | public: |
23 | Bkmk() : m_name(NULL), m_namelen(0), m_anno(NULL), m_annolen(0), m_position(0) {}; | 23 | Bkmk() : m_name(0), m_namelen(0), m_anno(0), m_annolen(0), m_position(0) {}; |
24 | Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); | 24 | Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); |
25 | Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); | 25 | Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); |
26 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); | 26 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); |
27 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2); | 27 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2); |
28 | Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL) | 28 | Bkmk(const Bkmk& rhs); |
29 | { | ||
30 | *this = rhs; | ||
31 | } | ||
32 | ~Bkmk(); | 29 | ~Bkmk(); |
33 | unsigned int value() const { return m_position; } | 30 | unsigned int value() const { return m_position; } |
34 | void value(unsigned int _v) { m_position = _v; } | 31 | void value(unsigned int _v) { m_position = _v; } |
35 | unsigned int value2() const { return m_position2; } | 32 | unsigned int value2() const { return m_position2; } |
36 | void value2(unsigned int _v) { m_position2 = _v; } | 33 | void value2(unsigned int _v) { m_position2 = _v; } |
37 | unsigned char red() { return m_red; } | 34 | unsigned char red() { return m_red; } |
38 | unsigned char green() { return m_green; } | 35 | unsigned char green() { return m_green; } |
39 | unsigned char blue() { return m_blue; } | 36 | unsigned char blue() { return m_blue; } |
40 | void red(unsigned char _v) { m_red = _v; } | 37 | void red(unsigned char _v) { m_red = _v; } |
41 | void green(unsigned char _v) { m_green = _v; } | 38 | void green(unsigned char _v) { m_green = _v; } |
42 | void blue(unsigned char _v) { m_blue = _v; } | 39 | void blue(unsigned char _v) { m_blue = _v; } |
43 | unsigned char level() { return m_level; } | 40 | unsigned char level() { return m_level; } |
44 | void level(unsigned char _v) { m_level = _v; } | 41 | void level(unsigned char _v) { m_level = _v; } |
45 | tchar *name() const { return (tchar*)m_name; } | 42 | tchar *name() const { return (tchar*)m_name; } |
46 | tchar *anno() const { return (tchar*)m_anno; } | 43 | tchar *anno() const { return (tchar*)m_anno; } |
47 | bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } | 44 | bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } |
48 | Bkmk& operator=(const Bkmk& rhs); | 45 | Bkmk& operator=(const Bkmk& rhs); |
49 | bool operator==(const Bkmk& rhs); | 46 | bool operator==(const Bkmk& rhs); |
50 | void setAnno(tchar* t); | 47 | void setAnno(tchar* t); |
51 | void setAnno(unsigned char* t, unsigned short len); | 48 | void setAnno(unsigned char* t, unsigned short len); |
52 | unsigned char* filedata() | 49 | unsigned char* filedata() |
53 | { | 50 | { |
54 | CFiledata fd(anno()); | 51 | CFiledata fd(anno()); |
55 | return m_anno+fd.length(); | 52 | return m_anno+fd.length(); |
56 | } | 53 | } |
57 | unsigned short filedatalen() | 54 | unsigned short filedatalen() |
58 | { | 55 | { |
59 | CFiledata fd(anno()); | 56 | CFiledata fd(anno()); |
60 | return m_annolen - fd.length(); | 57 | return m_annolen - fd.length(); |
61 | } | 58 | } |
62 | }; | 59 | }; |
63 | 60 | ||
64 | class BkmkFile | 61 | class BkmkFile |
65 | { | 62 | { |
66 | FILE* f; | 63 | FILE* f; |
67 | bool wt; | 64 | bool wt; |
68 | bool isUpgraded, m_extras; | 65 | bool isUpgraded, m_extras; |
69 | static const unsigned long magic; | 66 | static const unsigned long magic; |
70 | private: | 67 | private: |
71 | static Bkmk* read07(BkmkFile*, FILE*); | 68 | static Bkmk* read07(BkmkFile*, FILE*); |
72 | static Bkmk* read06(BkmkFile*, FILE*); | 69 | static Bkmk* read06(BkmkFile*, FILE*); |
73 | static Bkmk* read05(BkmkFile*, FILE*); | 70 | static Bkmk* read05(BkmkFile*, FILE*); |
74 | static Bkmk* read03(BkmkFile*, FILE*); | 71 | static Bkmk* read03(BkmkFile*, FILE*); |
75 | CList<Bkmk>* readall00(Bkmk*(*fn)(BkmkFile*, FILE*)); | 72 | CList<Bkmk>* readall00(Bkmk*(*fn)(BkmkFile*, FILE*)); |
76 | void write(const Bkmk& b); | 73 | void write(const Bkmk& b); |
77 | public: | 74 | public: |
78 | bool upgraded() { return isUpgraded; } | 75 | bool upgraded() { return isUpgraded; } |
79 | BkmkFile(const char *fnm, bool w, bool _x); | 76 | BkmkFile(const char *fnm, bool w, bool _x); |