Changeset 640
Legend:
- Unmodified
- Added
- Removed
-
trunk/utils.c
r637 r640 597 597 #endif 598 598 599 void xc_copy_zend_constant(zend_constant *c) /* {{{ */ 600 { 599 void xc_hash_copy_if(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, xc_if_func_t checker) /* {{{ */ 600 { 601 Bucket *p; 602 void *new_entry; 603 zend_bool setTargetPointer; 604 605 setTargetPointer = !target->pInternalPointer; 606 p = source->pListHead; 607 while (p) { 608 if (checker(p->pData)) { 609 if (setTargetPointer && source->pInternalPointer == p) { 610 target->pInternalPointer = NULL; 611 } 612 if (p->nKeyLength) { 613 zend_hash_quick_update(target, p->arKey, p->nKeyLength, p->h, p->pData, size, &new_entry); 614 } else { 615 zend_hash_index_update(target, p->h, p->pData, size, &new_entry); 616 } 617 if (pCopyConstructor) { 618 pCopyConstructor(new_entry); 619 } 620 } 621 p = p->pListNext; 622 } 623 if (!target->pInternalPointer) { 624 target->pInternalPointer = target->pListHead; 625 } 626 } 627 /* }}} */ 628 #ifdef HAVE_XCACHE_CONSTANT 629 static zend_bool xc_is_internal_zend_constant(zend_constant *c) /* {{{ */ 630 { 631 return (c->flags & CONST_PERSISTENT) ? 1 : 0; 632 } 633 /* }}} */ 634 void xc_zend_constant_ctor(zend_constant *c) /* {{{ */ 635 { 636 assert((c->flags & CONST_PERSISTENT)); 601 637 #ifdef IS_UNICODE 602 638 c->name.u = zend_ustrndup(c->name.u, c->name_len - 1); … … 604 640 c->name = zend_strndup(c->name, c->name_len - 1); 605 641 #endif 606 if (!(c->flags & CONST_PERSISTENT)) { 607 zval_copy_ctor(&c->value); 608 } 609 } 610 /* }}} */ 642 } 643 /* }}} */ 644 void xc_zend_constant_dtor(zend_constant *c) /* {{{ */ 645 { 646 free(ZSTR_U(c->name)); 647 } 648 /* }}} */ 649 void xc_copy_internal_zend_constants(HashTable *target, HashTable *source) /* {{{ */ 650 { 651 zend_constant tmp_const; 652 xc_hash_copy_if(target, source, (copy_ctor_func_t) xc_zend_constant_ctor, (void *) &tmp_const, sizeof(zend_constant), (xc_if_func_t) xc_is_internal_zend_constant); 653 } 654 /* }}} */ 655 #endif 611 656 xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */ 612 657 { … … 646 691 h = OG(zend_constants); 647 692 zend_hash_init_ex(&TG(zend_constants), 20, NULL, h->pDestructor, h->persistent, h->bApplyProtection); 693 xc_copy_internal_zend_constants(&TG(zend_constants), &XG(internal_constant_table)); 648 694 { 649 695 zend_constant tmp_const; 650 zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_ copy_zend_constant, (void *) &tmp_const, sizeof(tmp_const));696 zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_zend_constant_ctor, (void *) &tmp_const, sizeof(tmp_const)); 651 697 } 652 698 #endif -
trunk/utils.h
r637 r640 123 123 xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC); 124 124 void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC); 125 void xc_copy_zend_constant(zend_constant *c); 125 126 typedef zend_bool (*xc_if_func_t)(void *data); 127 128 void xc_hash_copy_if(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, xc_if_func_t checker); 129 #ifdef HAVE_XCACHE_CONSTANT 130 void xc_zend_constant_ctor(zend_constant *c); 131 void xc_zend_constant_dtor(zend_constant *c); 132 void xc_copy_internal_zend_constants(HashTable *target, HashTable *source); 133 #endif -
trunk/xcache.c
r638 r640 1854 1854 1855 1855 if (!XG(internal_table_copied)) { 1856 #ifdef HAVE_XCACHE_CONSTANT1857 zend_constant tmp_const;1858 #endif1859 1856 zend_function tmp_func; 1860 1857 xc_cest_t tmp_cest; … … 1867 1864 1868 1865 #ifdef HAVE_XCACHE_CONSTANT 1869 zend_hash_init_ex(&XG(internal_constant_table), 20, NULL, NULL, 1, 0);1866 zend_hash_init_ex(&XG(internal_constant_table), 20, NULL, (dtor_func_t) xc_zend_constant_dtor, 1, 0); 1870 1867 #endif 1871 1868 zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0); … … 1873 1870 1874 1871 #ifdef HAVE_XCACHE_CONSTANT 1875 zend_hash_copy(&XG(internal_constant_table), EG(zend_constants), (copy_ctor_func_t) xc_copy_zend_constant, &tmp_const, sizeof(tmp_const));1872 xc_copy_internal_zend_constants(&XG(internal_constant_table), EG(zend_constants)); 1876 1873 #endif 1877 1874 zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func)); … … 1934 1931 1935 1932 #ifdef HAVE_XCACHE_CONSTANT 1936 zend_hash_init_ex(&xcache_globals->internal_constant_table, 1, NULL, NULL, 1, 0);1933 zend_hash_init_ex(&xcache_globals->internal_constant_table, 1, NULL, (dtor_func_t) xc_zend_constant_dtor, 1, 0); 1937 1934 #endif 1938 1935 zend_hash_init_ex(&xcache_globals->internal_function_table, 1, NULL, NULL, 1, 0);

