efree(ldap_attrs);
}
- if (array_init(return_value) == FAILURE) {
- efree(lds);
- efree(rcs);
- RETURN_FALSE;
- }
+ array_init(return_value);
/* Collect results from the searches */
for (i=0; i<nlinks; i++) {
num_values = ldap_count_values(ldap_value);
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
for(i=0; i<num_values; i++) {
add_next_index_string(return_value, ldap_value[i], 1);
}
num_values = ldap_count_values_len(ldap_value_len);
- if (array_init(return_value) == FAILURE) {
- php_error(E_ERROR, "%s(): Cannot initialize return value", get_active_function_name(TSRMLS_C));
- RETURN_FALSE;
- }
+ array_init(return_value);
for (i=0; i<num_values; i++) {
add_next_index_stringl(return_value, ldap_value_len[i]->bv_val, ldap_value_len[i]->bv_len, 1);
while(ldap_value[i] != NULL) i++;
count = i;
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
add_assoc_long(return_value, "count", count);
for(i=0; i<count; i++) {
switch(myargcount) {
case 6 :
zval_dtor(*referrals);
- if (array_init(*referrals) == FAILURE) {
- php_error(E_ERROR, "%s(): Cannot initialize return value", get_active_function_name(TSRMLS_C));
- ldap_value_free(lreferrals);
- ldap_memfree(lerrmsg);
- ldap_memfree(lmatcheddn);
- RETURN_FALSE;
- }
+ array_init(*referrals);
if (lreferrals != NULL) {
refp = lreferrals;
while (*refp) {
}
zval_dtor(*referrals);
- if (array_init(*referrals) == FAILURE) {
- php_error(E_ERROR, "%s(): Cannot initialize return value", get_active_function_name(TSRMLS_C));
- ldap_value_free(lreferrals);
- RETURN_FALSE;
- }
+ array_init(*referrals);
if (lreferrals != NULL) {
refp = lreferrals;
while (*refp) {
n = php_mb_default_identify_list_size;
}
entry = (int *)emalloc(n*sizeof(int));
- if (entry != NULL) {
- MBSTRG(current_detect_order_list) = entry;
- MBSTRG(current_detect_order_list_size) = n;
- while (n > 0) {
- *entry++ = *list++;
- n--;
- }
+ MBSTRG(current_detect_order_list) = entry;
+ MBSTRG(current_detect_order_list_size) = n;
+ while (n > 0) {
+ *entry++ = *list++;
+ n--;
}
/* override original function. */
break;
case 'I':
case 'i':
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
entry = MBSTRG(http_input_list);
n = MBSTRG(http_input_list_size);
while (n > 0) {
char *name;
if (ZEND_NUM_ARGS() == 0) {
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
entry = MBSTRG(current_detect_order_list);
n = MBSTRG(current_detect_order_list_size);
while (n > 0) {
WRONG_PARAM_COUNT;
}
args = (pval ***)ecalloc(argc, sizeof(pval **));
- if (args == NULL) {
- RETURN_FALSE;
- }
if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
efree((void *)args);
WRONG_PARAM_COUNT;
from_encoding = mbfl_no_encoding_invalid;
stack_max = PHP_MBSTR_STACK_BLOCK_SIZE;
stack = (pval ***)emalloc(stack_max*sizeof(pval **));
- if (stack != NULL) {
- stack_level = 0;
- identd = mbfl_encoding_detector_new(elist, elistsz TSRMLS_CC);
- if (identd != NULL) {
- n = 2;
- while (n < argc || stack_level > 0) {
- if (stack_level <= 0) {
- var = args[n++];
- if (Z_TYPE_PP(var) == IS_ARRAY || Z_TYPE_PP(var) == IS_OBJECT) {
- target_hash = HASH_OF(*var);
- if (target_hash != NULL) {
- zend_hash_internal_pointer_reset(target_hash);
- }
- }
- } else {
- stack_level--;
- var = stack[stack_level];
- }
- if (Z_TYPE_PP(var) == IS_ARRAY || Z_TYPE_PP(var) == IS_OBJECT) {
- target_hash = HASH_OF(*var);
- if (target_hash != NULL) {
- while (zend_hash_get_current_data(target_hash, (void **) &hash_entry) != FAILURE) {
- zend_hash_move_forward(target_hash);
- if (Z_TYPE_PP(hash_entry) == IS_ARRAY || Z_TYPE_PP(hash_entry) == IS_OBJECT) {
- if (stack_level >= stack_max) {
- stack_max += PHP_MBSTR_STACK_BLOCK_SIZE;
- ptmp = erealloc(stack, sizeof(pval **)*stack_max);
- if (ptmp == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "stack err at %s:(%d)", __FILE__, __LINE__);
- continue;
- }
- stack = (pval ***)ptmp;
- }
- stack[stack_level] = var;
- stack_level++;
- var = hash_entry;
- target_hash = HASH_OF(*var);
- if (target_hash != NULL) {
- zend_hash_internal_pointer_reset(target_hash);
- continue;
- }
- } else if (Z_TYPE_PP(hash_entry) == IS_STRING) {
- string.val = (unsigned char *)Z_STRVAL_PP(hash_entry);
- string.len = Z_STRLEN_PP(hash_entry);
- if (mbfl_encoding_detector_feed(identd, &string TSRMLS_CC)) {
- goto detect_end; /* complete detecting */
- }
- }
- }
- }
- } else if (Z_TYPE_PP(var) == IS_STRING) {
- string.val = (unsigned char *)Z_STRVAL_PP(var);
- string.len = Z_STRLEN_PP(var);
- if (mbfl_encoding_detector_feed(identd, &string TSRMLS_CC)) {
- goto detect_end; /* complete detecting */
- }
- }
- }
-detect_end:
- from_encoding = mbfl_encoding_detector_judge(identd TSRMLS_CC);
- mbfl_encoding_detector_delete(identd TSRMLS_CC);
- }
- efree(stack);
- }
- if (from_encoding == mbfl_no_encoding_invalid) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to detect encoding");
- from_encoding = mbfl_no_encoding_pass;
- }
- }
- if (elist != NULL) {
- efree((void *)elist);
- }
- /* create converter */
- convd = NULL;
- if (from_encoding != mbfl_no_encoding_pass) {
- convd = mbfl_buffer_converter_new(from_encoding, to_encoding, 0 TSRMLS_CC);
- if (convd == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create converter");
- RETURN_FALSE;
- }
- mbfl_buffer_converter_illegal_mode(convd, MBSTRG(current_filter_illegal_mode) TSRMLS_CC);
- mbfl_buffer_converter_illegal_substchar(convd, MBSTRG(current_filter_illegal_substchar) TSRMLS_CC);
- }
-
- /* convert */
- if (convd != NULL) {
- stack_max = PHP_MBSTR_STACK_BLOCK_SIZE;
- stack = (pval ***)emalloc(stack_max*sizeof(pval **));
- if (stack != NULL) {
- stack_level = 0;
+ stack_level = 0;
+ identd = mbfl_encoding_detector_new(elist, elistsz TSRMLS_CC);
+ if (identd != NULL) {
n = 2;
while (n < argc || stack_level > 0) {
if (stack_level <= 0) {
if (stack_level >= stack_max) {
stack_max += PHP_MBSTR_STACK_BLOCK_SIZE;
ptmp = erealloc(stack, sizeof(pval **)*stack_max);
- if (ptmp == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "stack err at %s:(%d)", __FILE__, __LINE__);
- continue;
- }
stack = (pval ***)ptmp;
}
stack[stack_level] = var;
} else if (Z_TYPE_PP(hash_entry) == IS_STRING) {
string.val = (unsigned char *)Z_STRVAL_PP(hash_entry);
string.len = Z_STRLEN_PP(hash_entry);
- ret = mbfl_buffer_converter_feed_result(convd, &string, &result TSRMLS_CC);
- if (ret != NULL) {
- STR_FREE(Z_STRVAL_PP(hash_entry));
- Z_STRVAL_PP(hash_entry) = (char *)ret->val;
- Z_STRLEN_PP(hash_entry) = ret->len;
+ if (mbfl_encoding_detector_feed(identd, &string TSRMLS_CC)) {
+ goto detect_end; /* complete detecting */
}
}
}
} else if (Z_TYPE_PP(var) == IS_STRING) {
string.val = (unsigned char *)Z_STRVAL_PP(var);
string.len = Z_STRLEN_PP(var);
- ret = mbfl_buffer_converter_feed_result(convd, &string, &result TSRMLS_CC);
- if (ret != NULL) {
- STR_FREE(Z_STRVAL_PP(var));
- Z_STRVAL_PP(var) = (char *)ret->val;
- Z_STRLEN_PP(var) = ret->len;
+ if (mbfl_encoding_detector_feed(identd, &string TSRMLS_CC)) {
+ goto detect_end; /* complete detecting */
+ }
+ }
+ }
+detect_end:
+ from_encoding = mbfl_encoding_detector_judge(identd TSRMLS_CC);
+ mbfl_encoding_detector_delete(identd TSRMLS_CC);
+ }
+ efree(stack);
+
+ if (from_encoding == mbfl_no_encoding_invalid) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to detect encoding");
+ from_encoding = mbfl_no_encoding_pass;
+ }
+ }
+ if (elist != NULL) {
+ efree((void *)elist);
+ }
+ /* create converter */
+ convd = NULL;
+ if (from_encoding != mbfl_no_encoding_pass) {
+ convd = mbfl_buffer_converter_new(from_encoding, to_encoding, 0 TSRMLS_CC);
+ if (convd == NULL) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create converter");
+ RETURN_FALSE;
+ }
+ mbfl_buffer_converter_illegal_mode(convd, MBSTRG(current_filter_illegal_mode) TSRMLS_CC);
+ mbfl_buffer_converter_illegal_substchar(convd, MBSTRG(current_filter_illegal_substchar) TSRMLS_CC);
+ }
+
+ /* convert */
+ if (convd != NULL) {
+ stack_max = PHP_MBSTR_STACK_BLOCK_SIZE;
+ stack = (pval ***)emalloc(stack_max*sizeof(pval **));
+ stack_level = 0;
+ n = 2;
+ while (n < argc || stack_level > 0) {
+ if (stack_level <= 0) {
+ var = args[n++];
+ if (Z_TYPE_PP(var) == IS_ARRAY || Z_TYPE_PP(var) == IS_OBJECT) {
+ target_hash = HASH_OF(*var);
+ if (target_hash != NULL) {
+ zend_hash_internal_pointer_reset(target_hash);
}
}
+ } else {
+ stack_level--;
+ var = stack[stack_level];
+ }
+ if (Z_TYPE_PP(var) == IS_ARRAY || Z_TYPE_PP(var) == IS_OBJECT) {
+ target_hash = HASH_OF(*var);
+ if (target_hash != NULL) {
+ while (zend_hash_get_current_data(target_hash, (void **) &hash_entry) != FAILURE) {
+ zend_hash_move_forward(target_hash);
+ if (Z_TYPE_PP(hash_entry) == IS_ARRAY || Z_TYPE_PP(hash_entry) == IS_OBJECT) {
+ if (stack_level >= stack_max) {
+ stack_max += PHP_MBSTR_STACK_BLOCK_SIZE;
+ ptmp = erealloc(stack, sizeof(pval **)*stack_max);
+ stack = (pval ***)ptmp;
+ }
+ stack[stack_level] = var;
+ stack_level++;
+ var = hash_entry;
+ target_hash = HASH_OF(*var);
+ if (target_hash != NULL) {
+ zend_hash_internal_pointer_reset(target_hash);
+ continue;
+ }
+ } else if (Z_TYPE_PP(hash_entry) == IS_STRING) {
+ string.val = (unsigned char *)Z_STRVAL_PP(hash_entry);
+ string.len = Z_STRLEN_PP(hash_entry);
+ ret = mbfl_buffer_converter_feed_result(convd, &string, &result TSRMLS_CC);
+ if (ret != NULL) {
+ STR_FREE(Z_STRVAL_PP(hash_entry));
+ Z_STRVAL_PP(hash_entry) = (char *)ret->val;
+ Z_STRLEN_PP(hash_entry) = ret->len;
+ }
+ }
+ }
+ }
+ } else if (Z_TYPE_PP(var) == IS_STRING) {
+ string.val = (unsigned char *)Z_STRVAL_PP(var);
+ string.len = Z_STRLEN_PP(var);
+ ret = mbfl_buffer_converter_feed_result(convd, &string, &result TSRMLS_CC);
+ if (ret != NULL) {
+ STR_FREE(Z_STRVAL_PP(var));
+ Z_STRVAL_PP(var) = (char *)ret->val;
+ Z_STRLEN_PP(var) = ret->len;
+ }
}
- efree(stack);
}
+ efree(stack);
+
mbfl_buffer_converter_delete(convd TSRMLS_CC);
}
i = zend_hash_num_elements(target_hash);
if (i > 0) {
convmap = (int *)emalloc(i*sizeof(int));
- if (convmap != NULL) {
- mapelm = convmap;
- mapsize = 0;
- while (i > 0) {
- if (zend_hash_get_current_data(target_hash, (void **) &hash_entry) == FAILURE) {
- break;
- }
- convert_to_long_ex(hash_entry);
- *mapelm++ = Z_LVAL_PP(hash_entry);
- mapsize++;
- i--;
- zend_hash_move_forward(target_hash);
+ mapelm = convmap;
+ mapsize = 0;
+ while (i > 0) {
+ if (zend_hash_get_current_data(target_hash, (void **) &hash_entry) == FAILURE) {
+ break;
}
+ convert_to_long_ex(hash_entry);
+ *mapelm++ = Z_LVAL_PP(hash_entry);
+ mapsize++;
+ i--;
+ zend_hash_move_forward(target_hash);
}
}
}
convert_to_string_ex(type);
if (argc == 0 || !strcasecmp("all", Z_STRVAL_PP(type))) {
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
if ((name = (char *)mbfl_no_encoding2name(MBSTRG(current_internal_encoding))) != NULL) {
add_assoc_string(return_value, "internal_encoding", name, 1);
}
list_size += strlen(name) + 1;
if (!list) {
list = (char*)emalloc(list_size);
- if (!list) {
- return -1;
- }
*list = (char)NULL;
} else {
list = (char*)erealloc(list, list_size);
- if (!list) {
- return -1;
- }
strcat(list, ",");
}
strcat(list, name);
rc->options != options || rc->mbctype != mbctype) {
memset(pre, 0, sizeof(*pre));
pre->fastmap = (char*)emalloc((1 << MBRE_BYTEWIDTH)*sizeof(char));
- if (pre->fastmap) {
- pre->options = options;
- pre->mbctype = mbctype;
- err_str = mbre_compile_pattern(pattern, patlen, pre);
- if (!err_str) {
- zend_hash_update(&MBSTRG(ht_rc), (char *) pattern, patlen+1, (void *) pre, sizeof(*pre), NULL);
- } else {
- efree(pre->fastmap);
- pre->fastmap = (char*)0;
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "mbregex compile err: %s", err_str);
- res = 1;
- }
+ pre->options = options;
+ pre->mbctype = mbctype;
+ err_str = mbre_compile_pattern(pattern, patlen, pre);
+ if (!err_str) {
+ zend_hash_update(&MBSTRG(ht_rc), (char *) pattern, patlen+1, (void *) pre, sizeof(*pre), NULL);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate memory in mbregex_compile_pattern");
+ efree(pre->fastmap);
+ pre->fastmap = (char*)0;
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "mbregex compile err: %s", err_str);
res = 1;
}
} else {
if (count == 0) count = 1;
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
/* create regex pattern buffer */
err = php_mbregex_compile_pattern(
&re,
RETURN_FALSE;
}
+ array_init(return_value);
+
pos = 0;
err = 0;
/* churn through str, generating array entries as we go */
}
switch (mode) {
case 1:
- if (array_init(return_value) != FAILURE) {
- beg = MBSTRG(search_regs)->beg[0];
- end = MBSTRG(search_regs)->end[0];
- add_next_index_long(return_value, beg);
- add_next_index_long(return_value, end - beg);
- } else {
- RETVAL_FALSE;
- }
+ array_init(return_value);
+ beg = MBSTRG(search_regs)->beg[0];
+ end = MBSTRG(search_regs)->end[0];
+ add_next_index_long(return_value, beg);
+ add_next_index_long(return_value, end - beg);
break;
case 2:
- if (array_init(return_value) != FAILURE) {
- n = MBSTRG(search_regs)->num_regs;
- for (i = 0; i < n; i++) {
- beg = MBSTRG(search_regs)->beg[i];
- end = MBSTRG(search_regs)->end[i];
- if (beg >= 0 && beg <= end && end <= len) {
- add_index_stringl(return_value, i, (char *)&str[beg], end - beg, 1);
- } else {
- add_index_bool(return_value, i, 0);
- }
+ array_init(return_value);
+ n = MBSTRG(search_regs)->num_regs;
+ for (i = 0; i < n; i++) {
+ beg = MBSTRG(search_regs)->beg[i];
+ end = MBSTRG(search_regs)->end[i];
+ if (beg >= 0 && beg <= end && end <= len) {
+ add_index_stringl(return_value, i, (char *)&str[beg], end - beg, 1);
+ } else {
+ add_index_bool(return_value, i, 0);
}
- } else {
- RETVAL_FALSE;
}
break;
default: