summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-24 14:48:45 (UTC)
committer alwin <alwin>2003-12-24 14:48:45 (UTC)
commit52ccb19535d332f38dcd49f9d115192668c45357 (patch) (side-by-side diff)
treea13787f882b6b9c664ea91546ce502fcdeda9ed9
parent9d2a848b254d6c859d7054d486eedac6535d26ec (diff)
downloadopie-52ccb19535d332f38dcd49f9d115192668c45357.zip
opie-52ccb19535d332f38dcd49f9d115192668c45357.tar.gz
opie-52ccb19535d332f38dcd49f9d115192668c45357.tar.bz2
some small memleaks again
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp25
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp25
2 files changed, 22 insertions, 28 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index 0178e33..89ec7ab 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -156,14 +156,14 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
}
QList<Folder>* IMAPwrapper::listFolders()
{
const char *path, *mask;
int err = MAILIMAP_NO_ERROR;
- clist *result;
- clistcell *current;
+ clist *result = 0;
+ clistcell *current = 0;
QList<Folder> * folders = new QList<Folder>();
folders->setAutoDelete( false );
login();
if (!m_imap) {
return folders;
@@ -173,13 +173,12 @@ QList<Folder>* IMAPwrapper::listFolders()
* First we have to check for INBOX 'cause it sometimes it's not inside the path.
* We must not forget to filter them out in next loop!
* it seems like ugly code. and yes - it is ugly code. but the best way.
*/
QString temp;
mask = "INBOX" ;
- result = clist_new();
mailimap_mailbox_list *list;
err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
QString del;
if ( err == MAILIMAP_NO_ERROR ) {
current = result->first;
for ( int i = result->count; i > 0; i-- ) {
@@ -199,13 +198,12 @@ QList<Folder>* IMAPwrapper::listFolders()
/*
* second stage - get the other then inbox folders
*/
mask = "*" ;
path = account->getPrefix().latin1();
if (!path) path = "";
- result = clist_new();
qDebug(path);
bool selectable = true;
mailimap_mbx_list_flags*bflags;
err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
if ( err == MAILIMAP_NO_ERROR ) {
current = result->first;
@@ -225,13 +223,13 @@ QList<Folder>* IMAPwrapper::listFolders()
del = list->mb_delimiter;
folders->append(new IMAPFolder(temp,del,selectable,account->getPrefix()));
}
} else {
qDebug("error fetching folders %s",m_imap->imap_response);
}
- mailimap_list_result_free( result );
+ if (result) mailimap_list_result_free( result );
return folders;
}
RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
{
RecMail * m = 0;
@@ -344,18 +342,18 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
RecBody IMAPwrapper::fetchBody(const RecMail&mail)
{
RecBody body;
const char *mb;
int err = MAILIMAP_NO_ERROR;
- clist *result;
+ clist *result = 0;
clistcell *current;
- mailimap_fetch_att *fetchAtt;
- mailimap_fetch_type *fetchType;
- mailimap_set *set;
- mailimap_body*body_desc;
+ mailimap_fetch_att *fetchAtt = 0;
+ mailimap_fetch_type *fetchType = 0;
+ mailimap_set *set = 0;
+ mailimap_body*body_desc = 0;
mb = mail.getMbox().latin1();
login();
if (!m_imap) {
return body;
@@ -364,13 +362,12 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
err = mailimap_select( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->imap_response);
return body;
}
- result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
fetchAtt = mailimap_fetch_att_new_bodystructure();
fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
@@ -387,13 +384,13 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
qDebug("Mulitpart mail");
searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body);
}
} else {
qDebug("error fetching body: %s",m_imap->imap_response);
}
- mailimap_fetch_list_free(result);
+ if (result) mailimap_fetch_list_free(result);
return body;
}
/* this routine is just called when the mail has only ONE part.
for filling the parts of a multi-part-message there are other
routines 'cause we can not simply fetch the whole body. */
@@ -506,13 +503,13 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
mailimap_section * section = mailimap_section_new(section_spec);
mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section);
fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
- clist*result = clist_new();
+ clist*result = 0;
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
@@ -530,13 +527,13 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
}
}
}
} else {
qDebug("error fetching text: %s",m_imap->imap_response);
}
- mailimap_fetch_list_free(result);
+ if (result) mailimap_fetch_list_free(result);
return res;
}
void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList)
{
/* current_recursion is for avoiding ugly mails which has a to deep body-structure */
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 0178e33..89ec7ab 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -156,14 +156,14 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
}
QList<Folder>* IMAPwrapper::listFolders()
{
const char *path, *mask;
int err = MAILIMAP_NO_ERROR;
- clist *result;
- clistcell *current;
+ clist *result = 0;
+ clistcell *current = 0;
QList<Folder> * folders = new QList<Folder>();
folders->setAutoDelete( false );
login();
if (!m_imap) {
return folders;
@@ -173,13 +173,12 @@ QList<Folder>* IMAPwrapper::listFolders()
* First we have to check for INBOX 'cause it sometimes it's not inside the path.
* We must not forget to filter them out in next loop!
* it seems like ugly code. and yes - it is ugly code. but the best way.
*/
QString temp;
mask = "INBOX" ;
- result = clist_new();
mailimap_mailbox_list *list;
err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
QString del;
if ( err == MAILIMAP_NO_ERROR ) {
current = result->first;
for ( int i = result->count; i > 0; i-- ) {
@@ -199,13 +198,12 @@ QList<Folder>* IMAPwrapper::listFolders()
/*
* second stage - get the other then inbox folders
*/
mask = "*" ;
path = account->getPrefix().latin1();
if (!path) path = "";
- result = clist_new();
qDebug(path);
bool selectable = true;
mailimap_mbx_list_flags*bflags;
err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
if ( err == MAILIMAP_NO_ERROR ) {
current = result->first;
@@ -225,13 +223,13 @@ QList<Folder>* IMAPwrapper::listFolders()
del = list->mb_delimiter;
folders->append(new IMAPFolder(temp,del,selectable,account->getPrefix()));
}
} else {
qDebug("error fetching folders %s",m_imap->imap_response);
}
- mailimap_list_result_free( result );
+ if (result) mailimap_list_result_free( result );
return folders;
}
RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
{
RecMail * m = 0;
@@ -344,18 +342,18 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
RecBody IMAPwrapper::fetchBody(const RecMail&mail)
{
RecBody body;
const char *mb;
int err = MAILIMAP_NO_ERROR;
- clist *result;
+ clist *result = 0;
clistcell *current;
- mailimap_fetch_att *fetchAtt;
- mailimap_fetch_type *fetchType;
- mailimap_set *set;
- mailimap_body*body_desc;
+ mailimap_fetch_att *fetchAtt = 0;
+ mailimap_fetch_type *fetchType = 0;
+ mailimap_set *set = 0;
+ mailimap_body*body_desc = 0;
mb = mail.getMbox().latin1();
login();
if (!m_imap) {
return body;
@@ -364,13 +362,12 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
err = mailimap_select( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->imap_response);
return body;
}
- result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
fetchAtt = mailimap_fetch_att_new_bodystructure();
fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
@@ -387,13 +384,13 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
qDebug("Mulitpart mail");
searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body);
}
} else {
qDebug("error fetching body: %s",m_imap->imap_response);
}
- mailimap_fetch_list_free(result);
+ if (result) mailimap_fetch_list_free(result);
return body;
}
/* this routine is just called when the mail has only ONE part.
for filling the parts of a multi-part-message there are other
routines 'cause we can not simply fetch the whole body. */
@@ -506,13 +503,13 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
mailimap_section * section = mailimap_section_new(section_spec);
mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section);
fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
- clist*result = clist_new();
+ clist*result = 0;
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
@@ -530,13 +527,13 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
}
}
}
} else {
qDebug("error fetching text: %s",m_imap->imap_response);
}
- mailimap_fetch_list_free(result);
+ if (result) mailimap_fetch_list_free(result);
return res;
}
void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList)
{
/* current_recursion is for avoiding ugly mails which has a to deep body-structure */