summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2003-01-18 20:10:23 +0000
committerIlia Alshanetsky <iliaa@php.net>2003-01-18 20:10:23 +0000
commit984c0918ab9ea57077af09741a0a739533f1ffbb (patch)
tree5252178f3b0be20a4d480a9431e967aecb1110a8 /ext/mbstring/php_mbregex.c
parent71e9f8cdd5e66d64335fb5f657ac3f801e517b90 (diff)
downloadphp-git-984c0918ab9ea57077af09741a0a739533f1ffbb.tar.gz
Removed pointless memory allocation checks.
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r--ext/mbstring/php_mbregex.c61
1 files changed, 24 insertions, 37 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index c4b49eb7b0..ecf8183e34 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -238,20 +238,15 @@ php_mbregex_compile_pattern(mb_regex_t *pre, const char *pattern, int patlen, in
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 {
@@ -698,10 +693,6 @@ PHP_FUNCTION(mb_split)
if (count == 0) count = 1;
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
-
/* create regex pattern buffer */
err = php_mbregex_compile_pattern(
&re,
@@ -712,6 +703,8 @@ PHP_FUNCTION(mb_split)
RETURN_FALSE;
}
+ array_init(return_value);
+
pos = 0;
err = 0;
/* churn through str, generating array entries as we go */
@@ -895,29 +888,23 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
}
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: