Created
January 22, 2013 19:36
-
-
Save nikic/4597660 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* {{{ my_copy_property_info */ | |
static zend_property_info* my_copy_property_info(zend_property_info* dst, zend_property_info* src, apc_context_t* ctxt TSRMLS_DC) | |
{ | |
apc_pool* pool = ctxt->pool; | |
assert(src != NULL); | |
if (!dst) { | |
CHECK(dst = (zend_property_info*) apc_pool_alloc(pool, sizeof(*src))); | |
} | |
/* Start with a bitwise copy */ | |
memcpy(dst, src, sizeof(*src)); | |
dst->name = NULL; | |
#if defined(ZEND_ENGINE_2) && PHP_MINOR_VERSION > 0 | |
dst->doc_comment = NULL; | |
#endif | |
if (src->name) { | |
/* private members are stored inside property_info as a mangled | |
* string of the form: | |
* \0<classname>\0<membername>\0 | |
*/ | |
CHECK((dst->name = apc_string_pmemcpy((char *)src->name, src->name_length+1, pool TSRMLS_CC))); | |
} | |
#if defined(ZEND_ENGINE_2) && PHP_MINOR_VERSION > 0 | |
if (src->doc_comment) { | |
CHECK((dst->doc_comment = apc_pmemcpy(src->doc_comment, (src->doc_comment_len + 1), pool TSRMLS_CC))); | |
} | |
#endif | |
#if defined(ZEND_ENGINE_2_5) | |
if (src->accs) { | |
int i; | |
CHECK(dst->accs = (zend_function**) apc_pool_alloc(pool, ZEND_NUM_ACCESSORS * sizeof(zend_function *))); | |
for (i = 0; i < ZEND_NUM_ACCESSORS; ++i) { | |
if (src->accs[i]) { | |
dst->accs[i] = my_copy_function(NULL, src->accs[i], ctxt TSRMLS_CC); | |
} else { | |
dst->accs[i] = NULL; | |
} | |
} | |
} | |
#endif | |
return dst; | |
} | |
/* }}} */ | |
/* {{{ my_copy_property_info_for_execution */ | |
static zend_property_info* my_copy_property_info_for_execution(zend_property_info* dst, zend_property_info* src, apc_context_t* ctxt TSRMLS_DC) | |
{ | |
assert(src != NULL); | |
if (!dst) { | |
CHECK(dst = (zend_property_info*) apc_pool_alloc(ctxt->pool, sizeof(*src))); | |
} | |
/* Do a bitwise copy */ | |
memcpy(dst, src, sizeof(*src)); | |
#if defined(ZEND_ENGINE_2_5) | |
if (src->accs) { | |
int i; | |
dst->accs = (zend_function**) ecalloc(ZEND_NUM_ACCESSORS, sizeof(zend_function *)); | |
for (i = 0; i < ZEND_NUM_ACCESSORS; ++i) { | |
if (src->accs[i]) { | |
dst->accs[i] = apc_copy_function_for_execution_ex(NULL, src->accs[i], ctxt TSRMLS_CC); | |
} | |
} | |
} | |
#endif | |
return dst; | |
} | |
/* }}} */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment