Changeset 641 in svn for branches/1.3


Ignore:
Timestamp:
2009-07-05T16:56:27+02:00 (6 years ago)
Author:
Xuefer
Message:

merged r637,r634,r640 from trunk

Location:
branches/1.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/utils.c

    r636 r641  
    554554#endif
    555555
    556 static void xc_copy_zend_constant(zend_constant *c) /* {{{ */
    557 {
     556void 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
     586static zend_bool xc_is_internal_zend_constant(zend_constant *c) /* {{{ */
     587{
     588    return (c->flags & CONST_PERSISTENT) ? 1 : 0;
     589}
     590/* }}} */
     591void 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
    558597    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/* }}} */
     601void xc_zend_constant_dtor(zend_constant *c) /* {{{ */
     602{
     603    free(ZSTR_U(c->name));
     604}
     605/* }}} */
     606void 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
    564613xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */
    565614{
     
    599648    h = OG(zend_constants);
    600649    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));
    601651    {
    602652        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));
    604654    }
    605655#endif
  • branches/1.3/utils.h

    r627 r641  
    119119xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC);
    120120void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC);
     121
     122typedef zend_bool (*xc_if_func_t)(void *data);
     123
     124void 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
     126void xc_zend_constant_ctor(zend_constant *c);
     127void xc_zend_constant_dtor(zend_constant *c);
     128void xc_copy_internal_zend_constants(HashTable *target, HashTable *source);
     129#endif
  • branches/1.3/xcache.c

    r639 r641  
    15851585}
    15861586/* }}} */
    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 /* }}} */
    15951587static void xc_request_init(TSRMLS_D) /* {{{ */
    15961588{
     
    15981590
    15991591    if (!XG(internal_table_copied)) {
    1600 #ifdef HAVE_XCACHE_CONSTANT
    1601         zend_constant tmp_const;
    1602 #endif
    16031592        zend_function tmp_func;
    16041593        xc_cest_t tmp_cest;
     
    16111600
    16121601#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);
    16141603#endif
    16151604        zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0);
     
    16171606
    16181607#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));
    16201609#endif
    16211610        zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func));
     
    16781667
    16791668#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);
    16811670#endif
    16821671    zend_hash_init_ex(&xcache_globals->internal_function_table, 1, NULL, NULL, 1, 0);
     
    19581947        default:
    19591948#ifdef IS_UNICODE
    1960             convert_to_text(name);
     1949            convert_to_unicode(name);
    19611950#else
    19621951            convert_to_string(name);
Note: See TracChangeset for help on using the changeset viewer.