cvs: php4 /ext/imap php_imap.c php_imap.h
| From: | Chuck Hagenbuch | Date: | Thu, 16 Aug 2001 20:13:28 +0000 |
| Subject: | cvs: php4 /ext/imap php_imap.c php_imap.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6893@lists.php.net to get a copy of this message | ||
chagenbu Thu Aug 16 16:13:28 2001 EDT
Modified files:
/php4/ext/imap php_imap.c php_imap.h
Log:
add tail pointer to speed up imap_search (submitted by Rob Siemborski
<rjs3@andrew.cmu.edu>).
Index: php4/ext/imap/php_imap.c
diff -u php4/ext/imap/php_imap.c:1.100 php4/ext/imap/php_imap.c:1.101
--- php4/ext/imap/php_imap.c:1.100 Mon Aug 13 12:13:16 2001
+++ php4/ext/imap/php_imap.c Thu Aug 16 16:13:26 2001
@@ -25,7 +25,7 @@
| PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_imap.c,v 1.100 2001/08/13 16:13:16 andi Exp $ */
+/* $Id: php_imap.c,v 1.101 2001/08/16 20:13:26 chagenbu Exp $ */
#define IMAP41
@@ -336,8 +336,7 @@
*/
MESSAGELIST *mail_newmessagelist(void)
{
- return (MESSAGELIST *) memset(fs_get(sizeof(MESSAGELIST)), 0,
- sizeof(MESSAGELIST));
+ return (MESSAGELIST *) memset(fs_get(sizeof(MESSAGELIST)), 0, sizeof(MESSAGELIST));
}
/* }}} */
@@ -347,12 +346,17 @@
* Accepts: pointer to MESSAGELIST pointer
* Author: CJH
*/
-void mail_free_messagelist(MESSAGELIST **msglist)
+void mail_free_messagelist(MESSAGELIST **msglist, MESSAGELIST **tail)
{
- if (*msglist) { /* only free if exists */
- mail_free_messagelist (&(*msglist)->next);
- fs_give ((void **) msglist); /* return string to free storage */
+ MESSAGELIST *cur, *next;
+
+ for (cur = *msglist, next = cur->next; cur; cur = next) {
+ next = cur->next;
+ fs_give((void **)&cur);
}
+
+ *tail = NIL;
+ *msglist = NIL;
}
/* }}} */
@@ -381,15 +385,16 @@
*/
static void php_imap_init_globals(zend_imap_globals *imap_globals)
{
- imap_globals->imap_user=NIL;
- imap_globals->imap_password=NIL;
- imap_globals->imap_folders=NIL;
- imap_globals->imap_sfolders=NIL;
- imap_globals->imap_alertstack=NIL;
- imap_globals->imap_errorstack=NIL;
- imap_globals->imap_messages=NIL;
- imap_globals->imap_folder_objects=NIL;
- imap_globals->imap_sfolder_objects=NIL;
+ imap_globals->imap_user = NIL;
+ imap_globals->imap_password = NIL;
+ imap_globals->imap_folders = NIL;
+ imap_globals->imap_sfolders = NIL;
+ imap_globals->imap_alertstack = NIL;
+ imap_globals->imap_errorstack = NIL;
+ imap_globals->imap_messages = NIL;
+ imap_globals->imap_messages_tail = NIL;
+ imap_globals->imap_folder_objects = NIL;
+ imap_globals->imap_sfolder_objects = NIL;
imap_globals->folderlist_style = FLIST_ARRAY;
}
/* }}} */
@@ -3357,7 +3362,7 @@
flags = Z_LVAL_PP(search_flags);
}
- IMAPG(imap_messages) = NIL;
+ IMAPG(imap_messages) = IMAPG(imap_messages_tail) = NIL;
mail_search_full(imap_le_struct->imap_stream, NIL, mail_criteria(search_criteria), flags);
if (IMAPG(imap_messages) == NIL) {
efree(search_criteria);
@@ -3371,7 +3376,7 @@
add_next_index_long(return_value, cur->msgid);
cur = cur->next;
}
- mail_free_messagelist(&IMAPG(imap_messages));
+ mail_free_messagelist(&IMAPG(imap_messages), &IMAPG(imap_messages_tail));
efree(search_criteria);
}
/* }}} */
@@ -3895,20 +3900,19 @@
{
MESSAGELIST *cur = NIL;
TSRMLS_FETCH();
-
+
if (IMAPG(imap_messages) == NIL) {
IMAPG(imap_messages) = mail_newmessagelist();
IMAPG(imap_messages)->msgid = number;
IMAPG(imap_messages)->next = NIL;
+ IMAPG(imap_messages_tail) = IMAPG(imap_messages);
} else {
- cur = IMAPG(imap_messages);
- while (cur->next != NIL) {
- cur = cur->next;
- }
+ cur = IMAPG(imap_messages_tail);
cur->next = mail_newmessagelist();
cur = cur->next;
cur->msgid = number;
cur->next = NIL;
+ IMAPG(imap_messages_tail) = cur;
}
}
Index: php4/ext/imap/php_imap.h
diff -u php4/ext/imap/php_imap.h:1.14 php4/ext/imap/php_imap.h:1.15
--- php4/ext/imap/php_imap.h:1.14 Fri Aug 10 14:32:56 2001
+++ php4/ext/imap/php_imap.h Thu Aug 16 16:13:27 2001
@@ -26,7 +26,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_imap.h,v 1.14 2001/08/10 18:32:56 chagenbu Exp $ */
+/* $Id: php_imap.h,v 1.15 2001/08/16 20:13:27 chagenbu Exp $ */
#ifndef PHP_IMAP_H
#define PHP_IMAP_H
@@ -190,6 +190,7 @@
STRINGLIST *imap_alertstack;
ERRORLIST *imap_errorstack;
MESSAGELIST *imap_messages;
+ MESSAGELIST *imap_messages_tail;
FOBJECTLIST *imap_folder_objects;
FOBJECTLIST *imap_sfolder_objects;
folderlist_style_t folderlist_style;