Changeset 641 for branches/1.3/utils.c
- Timestamp:
- 2009-07-05T16:56:27+02:00 (4 years ago)
- Location:
- branches/1.3
- Files:
-
- 2 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
Note: See TracChangeset
for help on using the changeset viewer.

