From 3eee3a5fd679e11a2e4f36e18c8c4afc8372b347 Mon Sep 17 00:00:00 2001 From: Andrei Zmievski Date: Tue, 28 Mar 2006 04:33:29 +0000 Subject: [PATCH] Fix collator instantiation. --- ext/unicode/collator.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ext/unicode/collator.c b/ext/unicode/collator.c index 4cb5c249fb..3fb3bdc591 100644 --- a/ext/unicode/collator.c +++ b/ext/unicode/collator.c @@ -155,14 +155,18 @@ static void collator_object_free_storage(void *object TSRMLS_DC) static zval* collator_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) { + /* FIXME + * not sure what what this is for but moved here so it doesn't break stuff + * below + */ if (!object) { ALLOC_ZVAL(object); + object->refcount = 1; + object->is_ref = 1; } Z_TYPE_P(object) = IS_OBJECT; object_init_ex(object, pce); - object->refcount = 1; - object->is_ref = 1; return object; } @@ -177,13 +181,17 @@ PHP_FUNCTION(collator_create) UErrorCode error; char *collator_name; int collator_name_len; + zval *object; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &collator_name, &collator_name_len) == FAILURE) { RETURN_FALSE; } - collator_instantiate(unicode_ce_collator, return_value TSRMLS_CC); - collatorobj = (php_collator_obj *) zend_object_store_get_object(return_value TSRMLS_CC); + if ((object = getThis()) == NULL) { + object = return_value; + } + collator_instantiate(unicode_ce_collator, object TSRMLS_CC); + collatorobj = (php_collator_obj *) zend_object_store_get_object(object TSRMLS_CC); error = U_ZERO_ERROR; collatorobj->col = ucol_open(collator_name, &error); } -- 2.50.1