author | brad <brad> | 2004-04-06 11:58:24 (UTC) |
---|---|---|
committer | brad <brad> | 2004-04-06 11:58:24 (UTC) |
commit | 74c9cbe70b2a2530aad5e5a3cc8e0c946c560e95 (patch) (unidiff) | |
tree | af55d362e359414b2b18cef0c979d7e71e6a7d96 /libopie2/opiedb/osqlitedriver.cpp | |
parent | 52b7f68dd9435286a2d0b53fc8649b4323b8af38 (diff) | |
download | opie-74c9cbe70b2a2530aad5e5a3cc8e0c946c560e95.zip opie-74c9cbe70b2a2530aad5e5a3cc8e0c946c560e95.tar.gz opie-74c9cbe70b2a2530aad5e5a3cc8e0c946c560e95.tar.bz2 |
Fix memleak
Diffstat (limited to 'libopie2/opiedb/osqlitedriver.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiedb/osqlitedriver.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp index f07d520..3ba161e 100644 --- a/libopie2/opiedb/osqlitedriver.cpp +++ b/libopie2/opiedb/osqlitedriver.cpp | |||
@@ -127,41 +127,40 @@ bool OSQLiteDriver::open() { | |||
127 | qDebug("OSQLiteDriver::open: about to open"); | 127 | qDebug("OSQLiteDriver::open: about to open"); |
128 | m_sqlite = sqlite_open(m_url.local8Bit(), | 128 | m_sqlite = sqlite_open(m_url.local8Bit(), |
129 | 0, | 129 | 0, |
130 | &error ); | 130 | &error ); |
131 | 131 | ||
132 | /* failed to open */ | 132 | /* failed to open */ |
133 | if (m_sqlite == 0l ) { | 133 | if (m_sqlite == 0l ) { |
134 | // FIXME set the last error | 134 | // FIXME set the last error |
135 | qWarning("OSQLiteDriver::open: %s", error ); | 135 | qWarning("OSQLiteDriver::open: %s", error ); |
136 | free( error ); | 136 | free( error ); |
137 | return false; | 137 | return false; |
138 | } | 138 | } |
139 | sqreg = (sqregex *)malloc(sizeof(sqreg)); | ||
140 | sqlite_create_function(m_sqlite,"rlike",3,rlikeFunc,&sqreg); | 139 | sqlite_create_function(m_sqlite,"rlike",3,rlikeFunc,&sqreg); |
141 | return true; | 140 | return true; |
142 | } | 141 | } |
143 | 142 | ||
144 | 143 | ||
145 | /* close the db | 144 | /* close the db |
146 | * sqlite closes them without | 145 | * sqlite closes them without |
147 | * telling failure or success | 146 | * telling failure or success |
148 | */ | 147 | */ |
149 | bool OSQLiteDriver::close() { | 148 | bool OSQLiteDriver::close() { |
150 | if (m_sqlite ) | 149 | if (m_sqlite ) |
151 | sqlite_close( m_sqlite ), m_sqlite=0l; | 150 | sqlite_close( m_sqlite ), m_sqlite=0l; |
152 | if (sqreg->regex_raw != NULL){ | 151 | if (sqreg.regex_raw != NULL){ |
153 | free(sqreg->regex_raw); | 152 | free(sqreg.regex_raw); |
154 | sqreg->regex_raw=NULL; | 153 | sqreg.regex_raw=NULL; |
155 | regfree(&sqreg->regex_c); | 154 | regfree(&sqreg.regex_c); |
156 | } | 155 | } |
157 | return true; | 156 | return true; |
158 | } | 157 | } |
159 | 158 | ||
160 | 159 | ||
161 | /* Query */ | 160 | /* Query */ |
162 | OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { | 161 | OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { |
163 | if ( !m_sqlite ) { | 162 | if ( !m_sqlite ) { |
164 | // FIXME set error code | 163 | // FIXME set error code |
165 | OSQLResult result( OSQLResult::Failure ); | 164 | OSQLResult result( OSQLResult::Failure ); |
166 | return result; | 165 | return result; |
167 | } | 166 | } |