spl_object_storage_free_hash(intern, hash);
} /* }}} */
-void spl_object_storage_detach(spl_SplObjectStorage *intern, zval *this, zval *obj TSRMLS_DC) /* {{{ */
+int spl_object_storage_detach(spl_SplObjectStorage *intern, zval *this, zval *obj TSRMLS_DC) /* {{{ */
{
- int hash_len;
+ int hash_len, ret = FAILURE;
char *hash = spl_object_storage_get_hash(intern, this, obj, &hash_len TSRMLS_CC);
if (!hash) {
- return;
+ return ret;
}
- zend_hash_del(&intern->storage, hash, hash_len);
+ ret = zend_hash_del(&intern->storage, hash, hash_len);
spl_object_storage_free_hash(intern, hash);
+
+ return ret;
} /* }}}*/
void spl_object_storage_addall(spl_SplObjectStorage *intern, zval *this, spl_SplObjectStorage *other TSRMLS_DC) { /* {{{ */
spl_SplObjectStorage *intern = (spl_SplObjectStorage *)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_SplObjectStorage *other;
spl_SplObjectStorageElement *element;
- HashPosition pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, spl_ce_SplObjectStorage) == FAILURE) {
return;
other = (spl_SplObjectStorage *)zend_object_store_get_object(obj TSRMLS_CC);
- zend_hash_internal_pointer_reset_ex(&other->storage, &pos);
- while (zend_hash_get_current_data_ex(&other->storage, (void **)&element, &pos) == SUCCESS) {
- spl_object_storage_detach(intern, getThis(), element->obj TSRMLS_CC);
- zend_hash_move_forward_ex(&other->storage, &pos);
+ zend_hash_internal_pointer_reset(&other->storage);
+ while (zend_hash_get_current_data(&other->storage, (void **)&element) == SUCCESS) {
+ if (spl_object_storage_detach(intern, getThis(), element->obj TSRMLS_CC) == FAILURE) {
+ zend_hash_move_forward(&other->storage);
+ }
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);