[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] cvs: pecl /apc apc_compile.c apc_sma.c
From:       "Brian Shire" <shire () php ! net>
Date:       2006-12-26 22:37:36
Message-ID: cvsshire1167172656 () cvsserver
[Download RAW message or body]

shire		Tue Dec 26 22:37:36 2006 UTC

  Modified files:              
    /pecl/apc	apc_compile.c apc_sma.c 
  Log:
  - removed unecessary check/free 
  - moved deallocation to my_destroy_zval so circular refs don't double free
  - corrected mem_size_ptr values on apc_sma_free
  - set destination refcount/is_ref to source values
  - fixes bug #9653
  # a little hesitant about the refcount/is_ref change needed for circular refs, may \
need to review this if it causes problems  
  
http://cvs.php.net/viewvc.cgi/pecl/apc/apc_compile.c?r1=3.71&r2=3.72&diff_format=u
Index: pecl/apc/apc_compile.c
diff -u pecl/apc/apc_compile.c:3.71 pecl/apc/apc_compile.c:3.72
--- pecl/apc/apc_compile.c:3.71	Thu Dec  7 21:55:40 2006
+++ pecl/apc/apc_compile.c	Tue Dec 26 22:37:36 2006
@@ -28,7 +28,7 @@
 
  */
 
-/* $Id: apc_compile.c,v 3.71 2006/12/07 21:55:40 gopalv Exp $ */
+/* $Id: apc_compile.c,v 3.72 2006/12/26 22:37:36 shire Exp $ */
 
 #include "apc_compile.h"
 #include "apc_globals.h"
@@ -254,18 +254,13 @@
         return NULL;
     }
     dst_new = my_copy_zval(*dst, *src, allocate, deallocate);
-    if(!dst) {
-        deallocate(dst);
-        return NULL;
-    }
     if(dst_new != *dst) {
         deallocate(*dst);
         *dst = dst_new;
     }
 
-    /* deep-copying ensures that there is only one reference to this in memory */
-    (*dst)->refcount = 1;
-    (*dst)->is_ref = 0;
+    (*dst)->refcount = (*src)->refcount;
+    (*dst)->is_ref = (*src)->is_ref;
     
     return dst;
 }
@@ -1534,7 +1529,6 @@
 {
     assert(src != NULL);
     my_destroy_zval(src[0], deallocate);
-    deallocate(src[0]);
 }
 /* }}} */
 
@@ -1601,6 +1595,8 @@
         efree(APCG(copied_zvals));
         APCG(copied_zvals) = NULL;
     } 
+
+    deallocate(src);
 }
 /* }}} */
 
@@ -1830,7 +1826,6 @@
 static void my_free_zval_ptr(zval** src, apc_free_t deallocate)
 {
     my_destroy_zval_ptr(src, deallocate);
-    deallocate(src);
 }
 /* }}} */
 
@@ -1924,7 +1919,6 @@
 {
     if (src != NULL) {
         my_destroy_zval(src, deallocate);
-        deallocate(src);
     }
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/pecl/apc/apc_sma.c?r1=1.56&r2=1.57&diff_format=u
Index: pecl/apc/apc_sma.c
diff -u pecl/apc/apc_sma.c:1.56 pecl/apc/apc_sma.c:1.57
--- pecl/apc/apc_sma.c:1.56	Mon Dec 11 06:59:31 2006
+++ pecl/apc/apc_sma.c	Tue Dec 26 22:37:36 2006
@@ -26,7 +26,7 @@
 
  */
 
-/* $Id: apc_sma.c,v 1.56 2006/12/11 06:59:31 fmk Exp $ */
+/* $Id: apc_sma.c,v 1.57 2006/12/26 22:37:36 shire Exp $ */
 
 #include "apc_sma.h"
 #include "apc.h"
@@ -208,7 +208,7 @@
     block_t* cur;       /* the new block to insert */
     block_t* prv;       /* the block before cur */
     block_t* nxt;       /* the block after cur */
-    size_t size;           /* size of deallocated block */
+    size_t size;        /* size of deallocated block */
 
     offset -= alignword(sizeof(struct block_t));
     assert(offset >= 0);
@@ -410,6 +410,7 @@
 void apc_sma_free(void* p)
 {
     int i;
+    size_t offset;
     size_t d_size;
     TSRMLS_FETCH();
 
@@ -421,9 +422,9 @@
 
     for (i = 0; i < sma_numseg; i++) {
         LOCK(((header_t*)sma_shmaddrs[i])->sma_lock);
-        d_size = (size_t)((char *)p - (char *)(sma_shmaddrs[i]));
-        if (p >= sma_shmaddrs[i] && d_size < sma_segsize) {
-            sma_deallocate(sma_shmaddrs[i], d_size);
+        offset = (size_t)((char *)p - (char *)(sma_shmaddrs[i]));
+        if (p >= sma_shmaddrs[i] && offset < sma_segsize) {
+            d_size = sma_deallocate(sma_shmaddrs[i], offset);
             if (APCG(mem_size_ptr) != NULL) { *(APCG(mem_size_ptr)) -= d_size; }
             UNLOCK(((header_t*)sma_shmaddrs[i])->sma_lock);
             return;

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic