#endif
}
-static int zend_hash_unique_copy(HashTable *target, HashTable *source, unique_copy_ctor_func_t pCopyConstructor, uint size, int ignore_dups, void **fail_data, void **conflict_data)
+static void zend_accel_function_hash_copy(HashTable *target, HashTable *source, unique_copy_ctor_func_t pCopyConstructor TSRMLS_DC)
{
+ zend_function *function1, *function2;
+ uint idx;
Bucket *p;
- void *t;
-
- p = source->pListHead;
- while (p) {
- if (p->nKeyLength > 0) {
- if (zend_hash_quick_add(target, p->arKey, p->nKeyLength, p->h, p->pData, size, &t) == SUCCESS) {
- if (pCopyConstructor) {
- pCopyConstructor(t);
- }
- } else {
- if (p->nKeyLength > 0 && p->arKey[0] == 0) {
+ zval *t;
+
+ for (idx = 0; idx < source->nNumUsed; idx++) {
+ p = source->arData + idx;
+ if (Z_TYPE(p->val) == IS_UNDEF) continue;
+ if (p->key) {
+ t = zend_hash_add(target, p->key, &p->val);
+ if (UNEXPECTED(t == NULL)) {
+ if (p->key->len > 0 && p->key->val[0] == 0) {
/* Mangled key */
--#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO
- if (((zend_function*)Z_PTR(p->val))->common.fn_flags & ZEND_ACC_CLOSURE) {
- /* update closure */
- t = zend_hash_update(target, p->key, &p->val);
- } else {
- /* ignore and wait for runtime */
- continue;
- }
- #else
- /* ignore and wait for runtime */
- continue;
- if (zend_hash_quick_update(target, p->arKey, p->nKeyLength, p->h, p->pData, size, &t) == SUCCESS) {
- if (pCopyConstructor) {
- pCopyConstructor(t);
- }
- }
--#endif
- } else if (!ignore_dups && zend_hash_quick_find(target, p->arKey, p->nKeyLength, p->h, &t) == SUCCESS) {
- *fail_data = p->pData;
- *conflict_data = t;
- return FAILURE;
++ t = zend_hash_update(target, p->key, &p->val);
+ } else {
+ t = zend_hash_find(target, p->key);
+ goto failure;
}
}
} else {
#define PSF(a) PS(mod_user_names).name.ps_##a
- #define FINISH \
- if (!Z_ISUNDEF(retval)) { \
- convert_to_long(&retval); \
- ret = Z_LVAL(retval); \
- zval_ptr_dtor(&retval); \
- } \
+ #define FINISH \
- if (retval) { \
- if (Z_TYPE_P(retval) == IS_BOOL) { \
- ret = Z_BVAL_P(retval) ? SUCCESS : FAILURE; \
- } else if ((Z_TYPE_P(retval) == IS_LONG) && (Z_LVAL_P(retval) == -1)) { \
++ if (Z_TYPE(retval) != IS_UNDEF) { \
++ if (Z_TYPE(retval) == IS_TRUE) { \
++ ret = SUCCESS; \
++ } else if (Z_TYPE(retval) == IS_FALSE) { \
++ ret = FAILURE; \
++ } else if ((Z_TYPE(retval) == IS_LONG) && (Z_LVAL(retval) == -1)) { \
+ /* BC for clever users - Deprecate me */ \
+ ret = FAILURE; \
- } else if ((Z_TYPE_P(retval) == IS_LONG) && (Z_LVAL_P(retval) == 0)) { \
++ } else if ((Z_TYPE(retval) == IS_LONG) && (Z_LVAL(retval) == 0)) { \
+ /* BC for clever users - Deprecate me */ \
+ ret = SUCCESS; \
+ } else { \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Session callback expects true/false return value"); \
+ ret = FAILURE; \
++ zval_ptr_dtor(&retval); \
+ } \
- zval_ptr_dtor(&retval); \
+ } \
return ret
PS_OPEN_FUNC(user)
int buf_len;
const unsigned char *p, *s;
php_unserialize_data_t var_hash;
- zval *pmembers, *pflags = NULL;
+ zval members, zflags;
+ HashTable *aht;
long flags;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) {
return;
}
- if (aht->nApplyCount > 0) {
+ aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
++ if (aht->u.v.nApplyCount > 0) {
+ zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
+ return;
+ }
+
/* storage */
s = p = (const unsigned char*)buf;
PHP_VAR_UNSERIALIZE_INIT(var_hash);
llist->dtor(element TSRMLS_CC);
}
-
- zval_ptr_dtor((zval **)&element->data);
- element->data = NULL;
+ if (intern->traverse_pointer == element) {
+ SPL_LLIST_DELREF(element);
+ intern->traverse_pointer = NULL;
+ }
+ zval_ptr_dtor(&element->data);
+ ZVAL_UNDEF(&element->data);
SPL_LLIST_DELREF(element);
} else {
RETURN_FALSE;
}
- if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {
- if (len > INT_MAX) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "content truncated from %ld to %d bytes", len, INT_MAX);
- len = INT_MAX;
- }
- RETVAL_STRINGL(contents, len, 0);
- } else if (len == 0) {
- RETVAL_EMPTY_STRING();
++ if (maxlen > INT_MAX) {
++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "maxlen truncated from %ld to %d bytes", maxlen, INT_MAX);
++ maxlen = INT_MAX;
++ }
+ if ((contents = php_stream_copy_to_mem(stream, maxlen, 0)) != NULL) {
+ RETVAL_STR(contents);
} else {
- RETVAL_FALSE;
+ RETVAL_EMPTY_STRING();
}
php_stream_close(stream);
}
}
- len = php_stream_copy_to_mem(stream, &contents, maxlen, 0);
-
- if (contents) {
- if (len > INT_MAX) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "content truncated from %ld to %d bytes", len, INT_MAX);
- len = INT_MAX;
- }
- RETVAL_STRINGL(contents, len, 0);
++ if (maxlen > INT_MAX) {
++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "maxlen truncated from %ld to %d bytes", maxlen, INT_MAX);
++ maxlen = INT_MAX;
++ }
+ if ((contents = php_stream_copy_to_mem(stream, maxlen, 0))) {
+ RETURN_STR(contents);
} else {
- RETVAL_EMPTY_STRING();
+ RETURN_EMPTY_STRING();
}
}
/* }}} */
php_stream *innerstream;
size_t smax;
int mode;
- zval* meta;
+ zval meta;
+ char* tmpdir;
} php_stream_temp_data;
ret = 0;
}
- if (ts->meta) {
- zval_ptr_dtor(&ts->meta);
- }
+ zval_ptr_dtor(&ts->meta);
+ if (ts->tmpdir) {
+ efree(ts->tmpdir);
+ }
+
efree(ts);
return ret;
self = ecalloc(1, sizeof(*self));
self->smax = max_memory_usage;
self->mode = mode;
+ ZVAL_UNDEF(&self->meta);
+ if (tmpdir) {
+ self->tmpdir = estrdup(tmpdir);
+ }
stream = php_stream_alloc_rel(&php_stream_temp_ops, self, 0, mode & TEMP_STREAM_READONLY ? "rb" : "w+b");
stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
self->innerstream = php_stream_memory_create_rel(mode);