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;
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);
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);
"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;