Changeset 708 in svn for branches/1.3/utils.c


Ignore:
Timestamp:
2011-03-19T15:54:32+01:00 (4 years ago)
Author:
Xuefer
Message:

fixed #258: builtin constant memory leak on compile

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/utils.c

    r680 r708  
    600600}
    601601/* }}} */
     602static void xc_free_zend_constant(zend_constant *c) /* {{{ */
     603{
     604    if (!(c->flags & CONST_PERSISTENT)) {
     605        zval_dtor(&c->value);
     606    }
     607    free(ZSTR_V(c->name));
     608}
     609/* }}} */
    602610void xc_copy_internal_zend_constants(HashTable *target, HashTable *source) /* {{{ */
    603611{
     
    643651#ifdef HAVE_XCACHE_CONSTANT
    644652    h = OG(zend_constants);
    645     zend_hash_init_ex(&TG(zend_constants),  20, NULL, h->pDestructor, h->persistent, h->bApplyProtection);
     653    zend_hash_init_ex(&TG(zend_constants),  20, NULL, (dtor_func_t) xc_free_zend_constant, h->persistent, h->bApplyProtection);
    646654    xc_copy_internal_zend_constants(&TG(zend_constants), &XG(internal_constant_table));
    647     {
    648         zend_constant tmp_const;
    649         zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_zend_constant_ctor, (void *) &tmp_const, sizeof(tmp_const));
    650     }
    651655    TG(internal_constant_tail) = TG(zend_constants).pListTail;
    652656#endif
     
    712716
    713717#ifdef HAVE_XCACHE_CONSTANT
     718    for (b = TG(zend_constants).pListHead; b != NULL && b != TG(internal_constant_tail); b = b->pListNext) {
     719        zend_constant *c = (zend_constant*) b->pData;
     720        xc_free_zend_constant(c);
     721    }
     722
    714723    b = TG(internal_constant_tail) ? TG(internal_constant_tail)->pListNext : TG(zend_constants).pListHead;
    715724    /* install constants */
Note: See TracChangeset for help on using the changeset viewer.