From: Ilia Alshanetsky Date: Sat, 18 Jan 2003 19:28:10 +0000 (+0000) Subject: Removed pointless memory allocation checks. X-Git-Tag: PHP_5_0_dev_before_13561_fix~145 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72b356c1bccb511e9a3414cbfe6ff25b5a20b91f;p=php Removed pointless memory allocation checks. --- diff --git a/ext/ovrimos/ovrimos.c b/ext/ovrimos/ovrimos.c index 7b32b56731..1ba9860103 100644 --- a/ext/ovrimos/ovrimos.c +++ b/ext/ovrimos/ovrimos.c @@ -102,7 +102,6 @@ PHP_FUNCTION(ovrimos_connect) } state = ecalloc( 1, sizeof(CON_STATE)); - if (state==NULL) RETURN_FALSE; state->connection = conn; state->statements = NULL; @@ -185,10 +184,7 @@ int index, ret; if (!ret) return ret; state->nstatements++; - state->statements = erealloc( state->statements, - state->nstatements*sizeof( STATEMENT)); - - if (state->statements==NULL) return 0; + state->statements = erealloc(state->statements, state->nstatements*sizeof( STATEMENT)); index = state->nstatements - 1; state->statements[ index].statement = (*stmt); @@ -216,7 +212,6 @@ PCON_STATE state = statement->con_state; } new_statements = emalloc( (state->nstatements-1) * sizeof(STATEMENT)); - if (new_statements==NULL) return 0; for (i=j=0;instatements;i++) { if (state->statements->statement != stmt) { @@ -700,11 +695,7 @@ PHP_FUNCTION(ovrimos_fetch_into) } if (Z_TYPE_P(arr) != IS_ARRAY) { - if (array_init(arr) == FAILURE) { - php_error(E_WARNING, - "Can't convert to type Array"); - RETURN_FALSE; - } + array_init(arr); } switch (how) { case h_absolute: diff --git a/ext/pdf/pdf.c b/ext/pdf/pdf.c index 569bd49a4e..b294c4240e 100644 --- a/ext/pdf/pdf.c +++ b/ext/pdf/pdf.c @@ -2459,9 +2459,7 @@ PHP_FUNCTION(pdf_setpolydash) array = Z_ARRVAL_PP(arg2); len = zend_hash_num_elements(array); - if (NULL == (darray = emalloc(len * sizeof(double)))) { - RETURN_FALSE; - } + darray = emalloc(len * sizeof(double)); zend_hash_internal_pointer_reset(array); for (i=0; igr_name, 1); add_assoc_string(array_group, "passwd", g->gr_passwd, 1); @@ -779,12 +763,7 @@ PHP_FUNCTION(posix_getgrnam) RETURN_FALSE; } - if (array_init(return_value) == FAILURE) { - /* TODO: Should we issue a warning here so we don't have ambiguity - * with the above return value ? - */ - RETURN_FALSE; - } + array_init(return_value); if (!php_posix_group_to_array(g, return_value)) { php_error(E_WARNING, "%s() unable to convert posix group to array", @@ -809,12 +788,7 @@ PHP_FUNCTION(posix_getgrgid) RETURN_FALSE; } - if (array_init(return_value) == FAILURE) { - /* TODO: Should we issue a warning here so we don't have ambiguity - * with the above return value ? - */ - RETURN_FALSE; - } + array_init(return_value); if (!php_posix_group_to_array(g, return_value)) { php_error(E_WARNING, "%s() unable to convert posix group struct to array", @@ -856,9 +830,7 @@ PHP_FUNCTION(posix_getpwnam) RETURN_FALSE; } - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } + array_init(return_value); if (!php_posix_passwd_to_array(pw, return_value)) { php_error(E_WARNING, "%s() unable to convert posix passwd struct to array", @@ -884,9 +856,7 @@ PHP_FUNCTION(posix_getpwuid) RETURN_FALSE; } - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } + array_init(return_value); if (!php_posix_passwd_to_array(pw, return_value)) { php_error(E_WARNING, "%s() unable to convert posix passwd struct to array", @@ -1002,9 +972,7 @@ PHP_FUNCTION(posix_getrlimit) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) return; - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } + array_init(return_value); for (l=limits; l->name; l++) { if (posix_addlimit(l->limit, l->name, return_value TSRMLS_CC) == FAILURE) diff --git a/ext/pspell/pspell.c b/ext/pspell/pspell.c index 9945c8ddbf..15010eb7b0 100644 --- a/ext/pspell/pspell.c +++ b/ext/pspell/pspell.c @@ -355,9 +355,7 @@ PHP_FUNCTION(pspell_suggest) RETURN_FALSE; } - if (array_init(return_value) == FAILURE){ - RETURN_FALSE; - } + array_init(return_value); wl = pspell_manager_suggest(manager, Z_STRVAL_PP(word)); if(wl){ diff --git a/ext/qtdom/qtdom.c b/ext/qtdom/qtdom.c index 726b8bba23..77773d65fc 100644 --- a/ext/qtdom/qtdom.c +++ b/ext/qtdom/qtdom.c @@ -119,8 +119,7 @@ static int qdom_find_attributes( zval **children, struct qdom_attribute *attr TS count = 0; MAKE_STD_ZVAL(*children); - if (array_init(*children) == FAILURE) - return -1; + array_init(*children); for ( i = 0; i < attr->Count; ++i ) { node = qdom_do_attribute_at( attr, i ); @@ -158,8 +157,7 @@ static int qdom_find_children( zval **children, struct qdom_node *orig_node TSRM /* node = orig_node; */ MAKE_STD_ZVAL(*children); - if (array_init(*children) == FAILURE) - return -1; + array_init(*children); while( node ) { int num_childs, num_attrs; diff --git a/ext/session/session.c b/ext/session/session.c index 44fe30c147..a7d30ea65e 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1225,10 +1225,7 @@ PHP_FUNCTION(session_get_cookie_params) WRONG_PARAM_COUNT; } - if (array_init(return_value) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot initialize return value from session_get_cookie_parameters"); - RETURN_FALSE; - } + array_init(return_value); add_assoc_long(return_value, "lifetime", PS(cookie_lifetime)); add_assoc_string(return_value, "path", PS(cookie_path), 1); diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 13ba099536..c2366f1e47 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -473,10 +473,9 @@ PHP_MINFO_FUNCTION(sockets) /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(sockets) { - if ((SOCKETS_G(strerror_buf) = emalloc(16384))) - return SUCCESS; - - return FAILURE; + SOCKETS_G(strerror_buf) = emalloc(16384); + + return SUCCESS; } /* }}} */ diff --git a/ext/xml/php_xml.h b/ext/xml/php_xml.h index b1232c2c0b..2504f8b6c2 100644 --- a/ext/xml/php_xml.h +++ b/ext/xml/php_xml.h @@ -98,10 +98,6 @@ enum php_xml_option { PHP_XML_OPTION_SKIP_WHITE }; -#define RETURN_OUT_OF_MEMORY \ - php_error(E_WARNING, "Out of memory");\ - RETURN_FALSE - /* for xml_parse_into_struct */ #define XML_MAXLEVEL 255 /* XXX this should be dynamic */ diff --git a/ext/xml/xml.c b/ext/xml/xml.c index b40bc1743f..67c094c396 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -594,12 +594,7 @@ static void _xml_add_to_info(xml_parser *parser,char *name) if (zend_hash_find(Z_ARRVAL_P(parser->info),name,strlen(name) + 1,(void **) &element) == FAILURE) { MAKE_STD_ZVAL(values); - if (array_init(values) == FAILURE) { - TSRMLS_FETCH(); - - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array"); - return; - } + array_init(values); zend_hash_update(Z_ARRVAL_P(parser->info), name, strlen(name)+1, (void *) &values, sizeof(zval*), (void **) &element); } diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 0233d25033..1e62e99f8e 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -303,9 +303,7 @@ PHP_FUNCTION(gzfile) } /* Initialize return array */ - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } + array_init(return_value); /* Now loop through the file and do the magic quotes thing if needed */ memset(buf,0,sizeof(buf)); @@ -495,7 +493,6 @@ PHP_FUNCTION(gzuncompress) do { length=plength?plength:Z_STRLEN_PP(data)*(1<