Removed pointless memory allocation checks.

This commit is contained in:
Ilia Alshanetsky 2003-01-18 19:28:10 +00:00
parent 94c25df592
commit 72b356c1bc
11 changed files with 24 additions and 99 deletions

View file

@ -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;i<state->nstatements;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:

View file

@ -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; i<len; i++) {
zval *keydata, **keydataptr;

View file

@ -2442,9 +2442,7 @@ PHP_FUNCTION(pg_copy_to)
case PGRES_COPY_OUT:
if (pgsql_result) {
PQclear(pgsql_result);
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
array_init(return_value);
while (!copydone)
{
if ((ret = PQgetline(pgsql, copybuf, COPYBUFSIZ))) {
@ -3259,11 +3257,7 @@ static int php_pgsql_convert_match(const char *str, const char *regex , int icas
return FAILURE;
}
subs = (regmatch_t *)ecalloc(sizeof(regmatch_t), re.re_nsub+1);
if (!subs) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot allocate memory.");
regfree(&re);
return FAILURE;
}
regerr = regexec(&re, str, re.re_nsub+1, subs, 0);
if (regerr == REG_NOMATCH) {
#ifdef PHP_DEBUG
@ -3343,11 +3337,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
return FAILURE;
}
MAKE_STD_ZVAL(meta);
if (array_init(meta) == FAILURE) {
zval_dtor(meta);
FREE_ZVAL(meta);
return FAILURE;
}
array_init(meta);
if (php_pgsql_meta_data(pg_link, table_name, meta TSRMLS_CC) == FAILURE) {
zval_dtor(meta);
FREE_ZVAL(meta);

View file

@ -366,12 +366,7 @@ PHP_FUNCTION(posix_getgroups)
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);
for (i=0; i<result; i++) {
add_next_index_long(return_value, gidlist[i]);
@ -501,12 +496,7 @@ PHP_FUNCTION(posix_uname)
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);
add_assoc_string(return_value, "sysname", u.sysname, 1);
add_assoc_string(return_value, "nodename", u.nodename, 1);
@ -538,12 +528,7 @@ PHP_FUNCTION(posix_times)
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);
add_assoc_long(return_value, "ticks", ticks); /* clock ticks */
add_assoc_long(return_value, "utime", t.tms_utime); /* user time */
@ -736,8 +721,7 @@ int php_posix_group_to_array(struct group *g, zval *array_group) {
return 0;
MAKE_STD_ZVAL(array_members);
if (array_init(array_members) == FAILURE)
return 0;
array_init(array_members);
add_assoc_string(array_group, "name", g->gr_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)

View file

@ -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){

View file

@ -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;

View file

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

View file

@ -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;
}
/* }}} */

View file

@ -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 */

View file

@ -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);
}

View file

@ -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<<factor++);
s2 = (char *) erealloc(s1,length);
if(! s2) { if(s1) efree(s1); RETURN_FALSE; }
status = uncompress(s2, &length ,Z_STRVAL_PP(data), Z_STRLEN_PP(data));
s1=s2;
} while((status==Z_BUF_ERROR)&&(!plength)&&(factor<maxfactor));
@ -820,8 +817,6 @@ PHP_FUNCTION(gzencode)
stream.avail_out = stream.avail_in + (stream.avail_in/1000) + 15 + 1; /* room for \0 */
s2 = (char *) emalloc(stream.avail_out+GZIP_HEADER_LENGTH+(coding==CODING_GZIP?GZIP_FOOTER_LENGTH:0));
if(!s2)
RETURN_FALSE;
/* add gzip file header */
s2[0] = gz_magic[0];