summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2003-01-18 19:41:56 +0000
committerIlia Alshanetsky <iliaa@php.net>2003-01-18 19:41:56 +0000
commite2868b57885dac8a36593e2154c808038adc4cef (patch)
treeedb1421b5b3d4340a0e2538b996393874575b5f6
parent72b356c1bccb511e9a3414cbfe6ff25b5a20b91f (diff)
downloadphp-git-e2868b57885dac8a36593e2154c808038adc4cef.tar.gz
Removed pointless memory allocation checks.
-rw-r--r--ext/informix/ifx.ec16
-rw-r--r--ext/ingres_ii/ii.c4
-rw-r--r--ext/interbase/interbase.c11
-rw-r--r--ext/mcal/php_mcal.c8
-rw-r--r--ext/mcrypt/mcrypt.c14
-rw-r--r--ext/mnogosearch/php_mnogo.c8
-rw-r--r--ext/msql/php_msql.c4
-rw-r--r--ext/mssql/php_mssql.c15
-rw-r--r--ext/mysql/php_mysql.c8
-rw-r--r--ext/oci8/oci8.c5
-rw-r--r--ext/odbc/php_odbc.c9
-rw-r--r--ext/openssl/openssl.c7
-rw-r--r--ext/oracle/oracle.c35
13 files changed, 33 insertions, 111 deletions
diff --git a/ext/informix/ifx.ec b/ext/informix/ifx.ec
index 63ea78ac31..14ebcadd63 100644
--- a/ext/informix/ifx.ec
+++ b/ext/informix/ifx.ec
@@ -1741,9 +1741,7 @@ EXEC SQL END DECLARE SECTION;
}
Ifx_Result->rowid++;
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
num_fields = fieldcount;
locind = 0;
@@ -2365,9 +2363,7 @@ EXEC SQL END DECLARE SECTION;
EXEC SQL set connection :ifx;
PHP_IFX_CHECK_CONNECTION(ifx);
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
num_fields = fieldcount;
for (i = 1; i <= num_fields; i++) {
EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldname = NAME, :fieldtype = TYPE;
@@ -2523,9 +2519,7 @@ EXEC SQL END DECLARE SECTION;
EXEC SQL set connection :ifx;
PHP_IFX_CHECK_CONNECTION(ifx);
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
num_fields = fieldcount;
for (i = 1; i <= num_fields; i++) {
@@ -2681,9 +2675,7 @@ PHP_FUNCTION(ifx_getsqlca)
ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", le_result);
/* create pseudo-row array to return */
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
/* fill array with 6 fields sqlerrd0 .. sqlerrd5 */
/* each ESQLC call saves these sqlca values */
diff --git a/ext/ingres_ii/ii.c b/ext/ingres_ii/ii.c
index 8c1c3d4fb0..55e0c718df 100644
--- a/ext/ingres_ii/ii.c
+++ b/ext/ingres_ii/ii.c
@@ -1067,9 +1067,7 @@ static void php_ii_fetch(INTERNAL_FUNCTION_PARAMETERS, II_LINK *ii_link, int res
int len, should_copy, correct_length;
/* array initialization */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
/* going through all fields */
for (i = 1; i <= ii_link->fieldCount;) {
diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c
index 5fc17d4fdd..a6d9a8f683 100644
--- a/ext/interbase/interbase.c
+++ b/ext/interbase/interbase.c
@@ -1982,9 +1982,7 @@ static void _php_ibase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int fetch_type)
RETURN_FALSE;
}
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
arr_cnt = 0;
var = ib_result->out_sqlda->sqlvar;
@@ -2427,8 +2425,7 @@ PHP_FUNCTION(ibase_field_info)
if (Z_LVAL_PP(field_arg)<0 || Z_LVAL_PP(field_arg)>=ib_result->out_sqlda->sqld)
RETURN_FALSE;
- if (array_init(return_value)==FAILURE)
- RETURN_FALSE;
+ array_init(return_value);
var = ib_result->out_sqlda->sqlvar + Z_LVAL_PP(field_arg);
@@ -2762,9 +2759,7 @@ PHP_FUNCTION(ibase_blob_info)
GET_BLOB_ID_ARG(*blob_arg, ib_blob_id);
- if (array_init(return_value)==FAILURE){
- RETURN_FALSE;
- }
+ array_init(return_value);
if (ib_blob_id->bl_qd.gds_quad_high || ib_blob_id->bl_qd.gds_quad_low) { /*not null ?*/
if (isc_open_blob(IB_STATUS, &ib_blob_id->link, &ib_blob_id->trans_handle,
diff --git a/ext/mcal/php_mcal.c b/ext/mcal/php_mcal.c
index 5154c6b0c3..548da922ed 100644
--- a/ext/mcal/php_mcal.c
+++ b/ext/mcal/php_mcal.c
@@ -533,9 +533,7 @@ PHP_FUNCTION(mcal_list_events)
}
/* Initialize return array */
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
if (myargc == 7) {
convert_to_long_ex(startyear);
@@ -651,9 +649,7 @@ PHP_FUNCTION(mcal_list_alarms)
RETURN_FALSE;
}
- if (array_init(return_value) == FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
if (myargc == 7) {
convert_to_long_ex(year);
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
index 326e8bfa77..b40f8bc13a 100644
--- a/ext/mcrypt/mcrypt.c
+++ b/ext/mcrypt/mcrypt.c
@@ -210,12 +210,6 @@ ZEND_GET_MODULE(mcrypt)
return; \
}
-#define MCRYPT_INIT_RETURN_ARRAY \
- if (array_init(return_value) == FAILURE) { \
- php_error_docref (NULL TSRMLS_CC, E_ERROR, "Unable to initialize array"); \
- return; \
- }
-
#define MCRYPT_OPEN_MODULE_FAILED "Module initialization failed"
#define MCRYPT_ENTRY2_2_4(a,b) REGISTER_STRING_CONSTANT("MCRYPT_" #a, b, CONST_PERSISTENT)
@@ -546,7 +540,7 @@ PHP_FUNCTION(mcrypt_enc_get_supported_key_sizes)
int *key_sizes;
MCRYPT_GET_TD_ARG
- MCRYPT_INIT_RETURN_ARRAY
+ array_init(return_value);
key_sizes = mcrypt_enc_get_supported_key_sizes(td, &count);
@@ -797,7 +791,7 @@ PHP_FUNCTION(mcrypt_module_get_supported_key_sizes)
int *key_sizes;
MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir)
- MCRYPT_INIT_RETURN_ARRAY
+ array_init(return_value);
key_sizes = mcrypt_module_get_algo_supported_key_sizes(module, dir, &count);
@@ -823,7 +817,7 @@ PHP_FUNCTION(mcrypt_list_algorithms)
return;
}
- MCRYPT_INIT_RETURN_ARRAY
+ array_init(return_value);
modules = mcrypt_list_algorithms(lib_dir, &count);
if (count == 0) {
@@ -851,7 +845,7 @@ PHP_FUNCTION(mcrypt_list_modes)
return;
}
- MCRYPT_INIT_RETURN_ARRAY
+ array_init(return_value);
modules = mcrypt_list_modes(lib_dir, &count);
if (count == 0) {
diff --git a/ext/mnogosearch/php_mnogo.c b/ext/mnogosearch/php_mnogo.c
index 7a11442e50..0c0f7023e6 100644
--- a/ext/mnogosearch/php_mnogo.c
+++ b/ext/mnogosearch/php_mnogo.c
@@ -2265,9 +2265,7 @@ DLEXPORT PHP_FUNCTION(udm_cat_list)
#else
if((c=UdmCatList(Agent,cat))){
#endif
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
if (!(buf=calloc(1,UDMSTRSIZ+1))) {
RETURN_FALSE;
@@ -2339,9 +2337,7 @@ DLEXPORT PHP_FUNCTION(udm_cat_path)
#else
if((c=UdmCatPath(Agent,cat))){
#endif
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
if (!(buf=calloc(1,UDMSTRSIZ+1))) {
RETURN_FALSE;
diff --git a/ext/msql/php_msql.c b/ext/msql/php_msql.c
index be195fcd3a..956228d419 100644
--- a/ext/msql/php_msql.c
+++ b/ext/msql/php_msql.c
@@ -931,9 +931,7 @@ static void php_msql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
num_fields = msqlNumFields(msql_result);
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
msqlFieldSeek(msql_result,0);
for (msql_field=msqlFetchField(msql_result),i=0; msql_field; msql_field=msqlFetchField(msql_result),i++) {
diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c
index fa244f0c16..72b639b50c 100644
--- a/ext/mssql/php_mssql.c
+++ b/ext/mssql/php_mssql.c
@@ -1280,9 +1280,7 @@ static void php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
RETURN_FALSE;
}
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
for (i=0; i<result->num_fields; i++) {
if (Z_TYPE(result->data[result->cur_row][i]) != IS_NULL) {
@@ -1838,15 +1836,8 @@ PHP_FUNCTION(mssql_init)
statement=NULL;
statement = ecalloc(1,sizeof(mssql_statement));
-
- if (statement!=NULL) {
- statement->link = mssql_ptr;
- statement->executed=FALSE;
- }
- else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to allocate statement");
- RETURN_FALSE;
- }
+ statement->link = mssql_ptr;
+ statement->executed=FALSE;
statement->id = zend_list_insert(statement,le_statement);
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index d5d3544061..eeefc0aeda 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -1888,9 +1888,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
RETURN_FALSE;
}
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
mysql_field_seek(mysql_result, 0);
for (mysql_field=mysql_fetch_field(mysql_result), i=0; mysql_field; mysql_field=mysql_fetch_field(mysql_result), i++) {
@@ -2012,9 +2010,7 @@ PHP_FUNCTION(mysql_fetch_lengths)
if ((lengths=mysql_fetch_lengths(mysql_result))==NULL) {
RETURN_FALSE;
}
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
num_fields = mysql_num_fields(mysql_result);
for (i=0; i<num_fields; i++) {
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index a63474ee25..57be49c0e6 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -4034,10 +4034,7 @@ PHP_FUNCTION(ocifetchinto)
}
zval_dtor(*array);
- if (array_init(*array) == FAILURE) {
- php_error(E_WARNING, "OCIFetchInto: unable to convert arg 2 to array");
- RETURN_FALSE;
- }
+ array_init(*array);
for (i = 0; i < statement->ncolumns; i++) {
column = oci_get_col(statement, i + 1, 0);
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 575aff57b5..273ec51b95 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -1396,9 +1396,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
RETURN_FALSE;
}
- if (array_init(return_value)==FAILURE) {
- RETURN_FALSE;
- }
+ array_init(return_value);
#ifdef HAVE_SQL_EXTENDED_FETCH
if (result->fetch_abs) {
@@ -1552,10 +1550,7 @@ PHP_FUNCTION(odbc_fetch_into)
}
if (Z_TYPE_PP(pv_res_arr) != IS_ARRAY) {
- if (array_init(*pv_res_arr) == FAILURE) {
- php_error(E_WARNING, "Can't convert to type Array");
- RETURN_FALSE;
- }
+ array_init(*pv_res_arr);
}
#ifdef HAVE_SQL_EXTENDED_FETCH
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index a97961e954..dd125602b3 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -2875,12 +2875,7 @@ PHP_FUNCTION(openssl_seal)
ZVAL_STRINGL(sealdata, buf, len1 + len2, 0);
zval_dtor(ekeys);
- if (array_init(ekeys) == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot initialize return value");
- RETVAL_FALSE;
- efree(buf);
- goto clean_exit;
- }
+ array_init(ekeys);
for (i=0; i<nkeys; i++) {
eks[i][eksl[i]] = '\0';
add_next_index_stringl(ekeys, erealloc(eks[i], eksl[i] + 1), eksl[i], 0);
diff --git a/ext/oracle/oracle.c b/ext/oracle/oracle.c
index 0dc2814b36..fcd42689a3 100644
--- a/ext/oracle/oracle.c
+++ b/ext/oracle/oracle.c
@@ -619,10 +619,7 @@ PHP_FUNCTION(ora_open)
}
ZEND_FETCH_RESOURCE2(conn, oraConnection *, arg, -1, "Oracle-Connection", le_conn, le_pconn);
- if ((cursor = (oraCursor *)emalloc(sizeof(oraCursor))) == NULL){
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
+ cursor = (oraCursor *)emalloc(sizeof(oraCursor);
memset(cursor, 0, sizeof(oraCursor));
if (oopen(&cursor->cda, &conn->lda, (text *) 0, -1, -1, (text *) 0, -1)) {
php_error(E_WARNING, "Unable to open new cursor (%s)",
@@ -840,10 +837,7 @@ PHP_FUNCTION(ora_bind)
RETURN_FALSE;
}
}
- if ((newparam = (oraParam *)emalloc(sizeof(oraParam))) == NULL) {
- php_error(E_WARNING, "Out of memory for parameter");
- RETURN_FALSE;
- }
+ newparam = (oraParam *)emalloc(sizeof(oraParam);
if ((paramname = estrndup(Z_STRVAL_PP(pvar), Z_STRLEN_PP(pvar))) == NULL) {
php_error(E_WARNING, "Out of memory for parametername");
@@ -866,10 +860,7 @@ PHP_FUNCTION(ora_bind)
paramptr->progvl = Z_LVAL_PP(plen) + 1;
paramptr->inout = inout;
- if ((paramptr->progv = (text *)emalloc(paramptr->progvl)) == NULL) {
- php_error(E_WARNING, "Out of memory for parameter value");
- RETURN_FALSE;
- }
+ paramptr->progv = (text *)emalloc(paramptr->progvl);
/* XXX Maximum for progvl */
paramptr->alen = paramptr->progvl;
@@ -997,10 +988,7 @@ PHP_FUNCTION(ora_do)
convert_to_string_ex(sql);
- if ((cursor = (oraCursor *)emalloc(sizeof(oraCursor))) == NULL){
- php_error(E_WARNING, "Out of memory");
- RETURN_FALSE;
- }
+ cursor = (oraCursor *)emalloc(sizeof(oraCursor);
memset(cursor, 0, sizeof(oraCursor));
@@ -1137,10 +1125,7 @@ PHP_FUNCTION(ora_fetch_into)
if (Z_TYPE_PP(arr) != IS_ARRAY){
pval_destructor(*arr);
- if (array_init(*arr) == FAILURE){
- php_error(E_WARNING, "Can't convert to type Array");
- RETURN_FALSE;
- }
+ array_init(*arr);
}
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(arr));
@@ -1667,10 +1652,6 @@ ora_describe_define(oraCursor * cursor)
if (cursor->ncols > 0){
cursor->columns = (oraColumn *) emalloc(sizeof(oraColumn) * cursor->ncols);
- if (cursor->columns == NULL){
- php_error(E_WARNING, "Out of memory");
- return -1;
- }
memset(cursor->columns,0,sizeof(oraColumn) * cursor->ncols);
}
@@ -1704,10 +1685,8 @@ ora_describe_define(oraCursor * cursor)
break;
}
- if ((cursor->columns[col].buf = (ub1 *) emalloc(cursor->columns[col].dsize + 1)) == NULL){
- php_error(E_WARNING, "Out of memory");
- return -1;
- }
+ cursor->columns[col].buf = (ub1 *) emalloc(cursor->columns[col].dsize + 1);
+
/* Define an output variable for the column */
if (odefin(&cursor->cda, (sword)col + 1, cursor->columns[col].buf,
cursor->columns[col].dsize + 1, type, -1, &cursor->columns[col].indp,