andrei          Wed Aug 25 16:48:48 2004 EDT

  Modified files:              
    /php-src/ext/pcre   php_pcre.c 
  Log:
  MFB.
  
  
http://cvs.php.net/diff.php/php-src/ext/pcre/php_pcre.c?r1=1.160&r2=1.161&ty=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.160 php-src/ext/pcre/php_pcre.c:1.161
--- php-src/ext/pcre/php_pcre.c:1.160   Tue Aug 24 17:49:09 2004
+++ php-src/ext/pcre/php_pcre.c Wed Aug 25 16:48:48 2004
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcre.c,v 1.160 2004/08/24 21:49:09 helly Exp $ */
+/* $Id: php_pcre.c,v 1.161 2004/08/25 20:48:48 andrei Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -111,57 +111,16 @@
 #define PCRE_CACHE_SIZE 4096
 
 /* {{{ static pcre_clean_cache */
-static void pcre_clean_cache(TSRMLS_D)
+static int pcre_clean_cache(void *data, void *arg TSRMLS_DC)
 {
-       HashTable *ht = &PCRE_G(pcre_cache);
-       Bucket *p = NULL;
-       int clean_size = PCRE_CACHE_SIZE / 8;
+       int *num_clean = (int *)arg;
 
-       HANDLE_BLOCK_INTERRUPTIONS();
-
-       do {
-               p = ht->pListHead;
-
-               if (ht->pDestructor) {
-                       ht->pDestructor(p->pData);
-               }
-               if (!p->pDataPtr) {
-                       pefree(p->pData, ht->persistent);
-               }
-
-               if (p->pLast) {
-                       p->pLast->pNext = p->pNext;
-               } else {
-                       uint nIndex;
-
-                       nIndex = p->h & ht->nTableMask;
-                       ht->arBuckets[nIndex] = p->pNext;
-               }
-               if (p->pNext) {
-                       p->pNext->pLast = p->pLast;
-               } else {
-                       /* Nothing to do as this list doesn't have a tail */
-               }
-
-               if (p->pListLast != NULL) {
-                       p->pListLast->pListNext = p->pListNext;
-               } else {
-                       /* Deleting the head of the list */
-                       ht->pListHead = p->pListNext;
-               }
-               if (p->pListNext != NULL) {
-                       p->pListNext->pListLast = p->pListLast;
-               } else {
-                       ht->pListTail = p->pListLast;
-               }
-               if (ht->pInternalPointer == p) {
-                       ht->pInternalPointer = p->pListNext;
-               }
-               pefree(p, ht->persistent);
-               ht->nNumOfElements--;
-       } while (ht->nNumOfElements > PCRE_CACHE_SIZE - clean_size);
-
-       HANDLE_UNBLOCK_INTERRUPTIONS();
+       if (*num_clean > 0) {
+               (*num_clean)--;
+               return 1;
+       } else {
+               return 0;
+       }
 }
 /* }}} */
 
@@ -353,7 +312,8 @@
         * ones).
         */
        if (zend_hash_num_elements(&PCRE_G(pcre_cache)) == PCRE_CACHE_SIZE) {
-               pcre_clean_cache(TSRMLS_C);
+               int num_clean = PCRE_CACHE_SIZE / 8;
+               zend_hash_apply_with_argument(&PCRE_G(pcre_cache), pcre_clean_cache, 
&num_clean TSRMLS_CC);
        }
 
        /* Store the compiled pattern and extra info in the cache. */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to