From 424894de021f1be6fce205bea46de89838c8e600 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 30 Jun 2014 18:08:16 +0400 Subject: [PATCH] Fixed compilation problems --- .../rulebasedbreakiterator_methods.cpp | 8 ++--- ext/intl/idn/idn.c | 30 +++++++++---------- ext/intl/msgformat/msgformat_helpers.cpp | 8 ++--- ext/intl/timezone/timezone_methods.cpp | 4 +-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp index 36a3a8d20d..c13a432605 100644 --- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp @@ -217,10 +217,10 @@ U_CFUNC PHP_FUNCTION(rbbi_get_binary_rules) RETURN_FALSE; } - char *ret_rules = static_cast(emalloc(rules_len + 1)); - memcpy(ret_rules, rules, rules_len); - ret_rules[rules_len] = '\0'; + zend_string *ret_rules = STR_ALLOC(rules_len, 0); + memcpy(ret_rules->val, rules, rules_len); + ret_rules->val[rules_len] = '\0'; - RETURN_STRINGL(ret_rules, rules_len, 0); + RETURN_STR(ret_rules); } #endif diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c index f59fea494b..5b463ea58a 100644 --- a/ext/intl/idn/idn.c +++ b/ext/intl/idn/idn.c @@ -140,38 +140,39 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS, UIDNA *uts46; int32_t len; int32_t buffer_capac = 255; /* no domain name may exceed this */ - char *buffer = emalloc(buffer_capac); + zend_string *buffer = STR_ALLOC(buffer_capac, 0); UIDNAInfo info = UIDNA_INFO_INITIALIZER; int buffer_used = 0; uts46 = uidna_openUTS46(option, &status); if (php_intl_idn_check_status(status, "failed to open UIDNA instance", mode TSRMLS_CC) == FAILURE) { - efree(buffer); + STR_FREE(buffer); RETURN_FALSE; } if (mode == INTL_IDN_TO_ASCII) { len = uidna_nameToASCII_UTF8(uts46, domain, (int32_t)domain_len, - buffer, buffer_capac, &info, &status); + buffer->val, buffer_capac, &info, &status); } else { len = uidna_nameToUnicodeUTF8(uts46, domain, (int32_t)domain_len, - buffer, buffer_capac, &info, &status); + buffer->val, buffer_capac, &info, &status); } if (php_intl_idn_check_status(status, "failed to convert name", mode TSRMLS_CC) == FAILURE) { uidna_close(uts46); - efree(buffer); + STR_FREE(buffer); RETURN_FALSE; } if (len >= 255) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "ICU returned an unexpected length"); } - buffer[len] = '\0'; + buffer->val[len] = '\0'; + buffer->len = len; if (info.errors == 0) { - RETVAL_STRINGL(buffer, len, 0); + RETVAL_STR(buffer); buffer_used = 1; } else { RETVAL_FALSE; @@ -180,21 +181,20 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS, if (idna_info) { if (buffer_used) { /* used in return_value then */ zval_addref_p(return_value); - add_assoc_zval_ex(idna_info, "result", sizeof("result"), return_value); + add_assoc_zval_ex(idna_info, "result", sizeof("result")-1, return_value); } else { - zval *zv; - ALLOC_INIT_ZVAL(zv); - ZVAL_STRINGL(zv, buffer, len, 0); + zval zv; + ZVAL_STR(&zv, buffer); buffer_used = 1; - add_assoc_zval_ex(idna_info, "result", sizeof("result"), zv); + add_assoc_zval_ex(idna_info, "result", sizeof("result")-1, &zv); } add_assoc_bool_ex(idna_info, "isTransitionalDifferent", - sizeof("isTransitionalDifferent"), info.isTransitionalDifferent); - add_assoc_long_ex(idna_info, "errors", sizeof("errors"), (long)info.errors); + sizeof("isTransitionalDifferent")-1, info.isTransitionalDifferent); + add_assoc_long_ex(idna_info, "errors", sizeof("errors")-1, (long)info.errors); } if (!buffer_used) { - efree(buffer); + STR_FREE(buffer); } uidna_close(uts46); diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index fc7315aefc..1c18c6c969 100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp @@ -183,10 +183,10 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo, if (name_part.getType() == UMSGPAT_PART_TYPE_ARG_NAME) { UnicodeString argName = mp.getSubstring(name_part); - if ((storedType = zend_hash_str_find_ptr(ret, (char*)argName.getBuffer(), argName.length())) == NULL) { + if ((storedType = (Formattable::Type*)zend_hash_str_find_ptr(ret, (char*)argName.getBuffer(), argName.length())) == NULL) { /* not found already; create new entry in HT */ Formattable::Type bogusType = Formattable::kObject; - if ((storedType = zend_hash_str_update_mem(ret, (char*)argName.getBuffer(), argName.length(), + if ((storedType = (Formattable::Type*)zend_hash_str_update_mem(ret, (char*)argName.getBuffer(), argName.length(), (void*)&bogusType, sizeof(bogusType))) == NULL) { intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR, "Write to argument types hash table failed", 0 TSRMLS_CC); @@ -200,10 +200,10 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo, "Found part with negative number", 0 TSRMLS_CC); continue; } - if ((storedType = zend_hash_index_find_ptr(ret, (ulong)argNumber)) == NULL) { + if ((storedType = (Formattable::Type*)zend_hash_index_find_ptr(ret, (ulong)argNumber)) == NULL) { /* not found already; create new entry in HT */ Formattable::Type bogusType = Formattable::kObject; - if ((storedType = zend_hash_index_update_mem(ret, (ulong)argNumber, (void*)&bogusType, sizeof(bogusType))) == NULL) { + if ((storedType = (Formattable::Type*)zend_hash_index_update_mem(ret, (ulong)argNumber, (void*)&bogusType, sizeof(bogusType))) == NULL) { intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR, "Write to argument types hash table failed", 0 TSRMLS_CC); continue; diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp index cde090c243..2b1bcfab92 100644 --- a/ext/intl/timezone/timezone_methods.cpp +++ b/ext/intl/timezone/timezone_methods.cpp @@ -245,9 +245,9 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration) /* must come before zpp because zpp would convert the arg in the stack to 0 */ if (ZEND_NUM_ARGS() == 3) { - zval **dummy, **zvoffset; + zval *dummy, *zvoffset; arg3isnull = zend_get_parameters_ex(3, &dummy, &dummy, &zvoffset) - != FAILURE && Z_TYPE_PP(zvoffset) == IS_NULL; + != FAILURE && Z_TYPE_P(zvoffset) == IS_NULL; } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s!l", -- 2.40.0