Changeset 641
- Timestamp:
- 2009-07-05T16:56:27+02:00 (4 years ago)
- Location:
- branches/1.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
-
branches/1.3/utils.c
r636 r641 554 554 #endif 555 555 556 static void xc_copy_zend_constant(zend_constant *c) /* {{{ */ 557 { 556 void xc_hash_copy_if(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, xc_if_func_t checker) /* {{{ */ 557 { 558 Bucket *p; 559 void *new_entry; 560 zend_bool setTargetPointer; 561 562 setTargetPointer = !target->pInternalPointer; 563 p = source->pListHead; 564 while (p) { 565 if (checker(p->pData)) { 566 if (setTargetPointer && source->pInternalPointer == p) { 567 target->pInternalPointer = NULL; 568 } 569 if (p->nKeyLength) { 570 zend_hash_quick_update(target, p->arKey, p->nKeyLength, p->h, p->pData, size, &new_entry); 571 } else { 572 zend_hash_index_update(target, p->h, p->pData, size, &new_entry); 573 } 574 if (pCopyConstructor) { 575 pCopyConstructor(new_entry); 576 } 577 } 578 p = p->pListNext; 579 } 580 if (!target->pInternalPointer) { 581 target->pInternalPointer = target->pListHead; 582 } 583 } 584 /* }}} */ 585 #ifdef HAVE_XCACHE_CONSTANT 586 static zend_bool xc_is_internal_zend_constant(zend_constant *c) /* {{{ */ 587 { 588 return (c->flags & CONST_PERSISTENT) ? 1 : 0; 589 } 590 /* }}} */ 591 void xc_zend_constant_ctor(zend_constant *c) /* {{{ */ 592 { 593 assert((c->flags & CONST_PERSISTENT)); 594 #ifdef IS_UNICODE 595 c->name.u = zend_ustrndup(c->name.u, c->name_len - 1); 596 #else 558 597 c->name = zend_strndup(c->name, c->name_len - 1); 559 if (!(c->flags & CONST_PERSISTENT)) { 560 zval_copy_ctor(&c->value); 561 } 562 } 563 /* }}} */ 598 #endif 599 } 600 /* }}} */ 601 void xc_zend_constant_dtor(zend_constant *c) /* {{{ */ 602 { 603 free(ZSTR_U(c->name)); 604 } 605 /* }}} */ 606 void xc_copy_internal_zend_constants(HashTable *target, HashTable *source) /* {{{ */ 607 { 608 zend_constant tmp_const; 609 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); 610 } 611 /* }}} */ 612 #endif 564 613 xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */ 565 614 { … … 599 648 h = OG(zend_constants); 600 649 zend_hash_init_ex(&TG(zend_constants), 20, NULL, h->pDestructor, h->persistent, h->bApplyProtection); 650 xc_copy_internal_zend_constants(&TG(zend_constants), &XG(internal_constant_table)); 601 651 { 602 652 zend_constant tmp_const; 603 zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_ copy_zend_constant, (void *) &tmp_const, sizeof(tmp_const));653 zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_zend_constant_ctor, (void *) &tmp_const, sizeof(tmp_const)); 604 654 } 605 655 #endif -
branches/1.3/utils.h
r627 r641 119 119 xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC); 120 120 void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC); 121 122 typedef zend_bool (*xc_if_func_t)(void *data); 123 124 void xc_hash_copy_if(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, xc_if_func_t checker); 125 #ifdef HAVE_XCACHE_CONSTANT 126 void xc_zend_constant_ctor(zend_constant *c); 127 void xc_zend_constant_dtor(zend_constant *c); 128 void xc_copy_internal_zend_constants(HashTable *target, HashTable *source); 129 #endif -
branches/1.3/xcache.c
r639 r641 1585 1585 } 1586 1586 /* }}} */ 1587 static void xc_copy_zend_constant(zend_constant *c) /* {{{ */1588 {1589 c->name = zend_strndup(c->name, c->name_len - 1);1590 if (!(c->flags & CONST_PERSISTENT)) {1591 zval_copy_ctor(&c->value);1592 }1593 }1594 /* }}} */1595 1587 static void xc_request_init(TSRMLS_D) /* {{{ */ 1596 1588 { … … 1598 1590 1599 1591 if (!XG(internal_table_copied)) { 1600 #ifdef HAVE_XCACHE_CONSTANT1601 zend_constant tmp_const;1602 #endif1603 1592 zend_function tmp_func; 1604 1593 xc_cest_t tmp_cest; … … 1611 1600 1612 1601 #ifdef HAVE_XCACHE_CONSTANT 1613 zend_hash_init_ex(&XG(internal_constant_table), 20, NULL, NULL, 1, 0);1602 zend_hash_init_ex(&XG(internal_constant_table), 20, NULL, (dtor_func_t) xc_zend_constant_dtor, 1, 0); 1614 1603 #endif 1615 1604 zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0); … … 1617 1606 1618 1607 #ifdef HAVE_XCACHE_CONSTANT 1619 zend_hash_copy(&XG(internal_constant_table), EG(zend_constants), (copy_ctor_func_t) xc_copy_zend_constant, &tmp_const, sizeof(tmp_const));1608 xc_copy_internal_zend_constants(&XG(internal_constant_table), EG(zend_constants)); 1620 1609 #endif 1621 1610 zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func)); … … 1678 1667 1679 1668 #ifdef HAVE_XCACHE_CONSTANT 1680 zend_hash_init_ex(&xcache_globals->internal_constant_table, 1, NULL, NULL, 1, 0);1669 zend_hash_init_ex(&xcache_globals->internal_constant_table, 1, NULL, (dtor_func_t) xc_zend_constant_dtor, 1, 0); 1681 1670 #endif 1682 1671 zend_hash_init_ex(&xcache_globals->internal_function_table, 1, NULL, NULL, 1, 0); … … 1958 1947 default: 1959 1948 #ifdef IS_UNICODE 1960 convert_to_ text(name);1949 convert_to_unicode(name); 1961 1950 #else 1962 1951 convert_to_string(name);
Note: See TracChangeset
for help on using the changeset viewer.

