]> granicus.if.org Git - php/commitdiff
Removed pointless memory allocation checks.
authorIlia Alshanetsky <iliaa@php.net>
Sat, 18 Jan 2003 20:01:46 +0000 (20:01 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sat, 18 Jan 2003 20:01:46 +0000 (20:01 +0000)
ext/standard/exec.c
ext/standard/file.c
ext/standard/image.c
ext/standard/info.c
ext/standard/metaphone.c
ext/standard/string.c

index d617e8522645f37c0a8e1f90cee065fd5f54352b..13ed72a6ac55b9042188a205a2566e67c42ee38d 100644 (file)
@@ -67,10 +67,6 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value TSRMLS_DC)
 #endif
 
        buf = (char *) emalloc(EXEC_INPUT_BUF);
-       if (!buf) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to emalloc %d bytes for exec buffer", EXEC_INPUT_BUF);
-               return -1;
-       }
        buflen = EXEC_INPUT_BUF;
 
        if (PG(safe_mode)) {
@@ -162,14 +158,6 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value TSRMLS_DC)
                        do {
                                if ( buflen <= (l+1) ) {
                                        buf = erealloc(buf, buflen + EXEC_INPUT_BUF);
-                                       if ( buf == NULL ) {
-                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to erealloc %d bytes for exec buffer", 
-                                                               buflen + EXEC_INPUT_BUF);
-#if PHP_SIGCHILD
-                                               signal (SIGCHLD, sig_handler);
-#endif
-                                               return -1;
-                                       }
                                        buflen += EXEC_INPUT_BUF;
                                }
 
index dcdd3a9b3e38c4826950ae83f63d9a08d88b5aec..baacdc91292f2efb54de1dbc33679fb817e82a80 100644 (file)
@@ -1495,7 +1495,7 @@ PHP_FUNCTION(fscanf)
                WRONG_PARAM_COUNT;
        }
        args = (zval ***)emalloc(argCount * sizeof(zval **));
-       if (!args || (zend_get_parameters_array_ex(argCount, args) == FAILURE)) {
+       if (zend_get_parameters_array_ex(argCount, args) == FAILURE) {
                efree( args );
                WRONG_PARAM_COUNT;
        }
index 2b06e0ed39092b8244c6e4fff88ca5c258c83850..c16ee1c6f9af51188b892310d69677bd2cd34e86 100644 (file)
@@ -215,10 +215,6 @@ static struct gfxinfo *php_handle_swc(php_stream * stream TSRMLS_DC)
                do {
                        szlength=slength*(1<<factor++);
                        buf = (char *) erealloc(buf,szlength);
-                       if (!buf) {
-                               status = 1;
-                               break;
-                       } 
                        status = uncompress(buf, &szlength, bufz, slength);
                } while ((status==Z_BUF_ERROR)&&(factor<maxfactor));
                
@@ -439,7 +435,6 @@ static void php_read_APP(php_stream * stream, unsigned int marker, zval *info TS
        length -= 2;                            /* length includes itself */
 
        buffer = emalloc(length);
-       if ( !buffer) return;
 
        if (php_stream_read(stream, buffer, (long) length) <= 0) {
                efree(buffer);
@@ -485,8 +480,6 @@ static struct gfxinfo *php_handle_jpeg (php_stream * stream, pval *info TSRMLS_D
                                if (result == NULL) {
                                        /* handle SOFn block */
                                        result = (struct gfxinfo *) ecalloc(1, sizeof(struct gfxinfo));
-                                       if ( !result)
-                                               return NULL;
                                        length = php_read2(stream TSRMLS_CC);
                                        result->bits     = php_stream_getc(stream);
                                        result->height   = php_read2(stream TSRMLS_CC);
@@ -605,9 +598,6 @@ static struct gfxinfo *php_handle_jpc(php_stream * stream TSRMLS_DC)
        }
 
        result = (struct gfxinfo *)ecalloc(1, sizeof(struct gfxinfo));
-       if (!result) {
-               return NULL;
-       }
 
        dummy_short = php_read2(stream TSRMLS_CC); /* Lsiz */
        dummy_short = php_read2(stream TSRMLS_CC); /* Rsiz */
index 12cad0e948c6efd8c6dee50b77ead50241280127..3a521ef3d06a5c28e6733063d85153fa2e1bce04 100644 (file)
@@ -439,10 +439,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
                                for (zend_hash_internal_pointer_reset(url_stream_wrappers_hash);
                                                zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, NULL, 0, NULL) == HASH_KEY_IS_STRING;
                                                zend_hash_move_forward(url_stream_wrappers_hash)) {
-                                       if (NULL == (stream_protocols_buf = erealloc(stream_protocols_buf,
-                                                                       stream_protocols_buf_len + stream_protocol_len + 2 /* ", " */ + 1 /* 0 byte at end */))) {
-                                               break;
-                                       }
+                                       stream_protocols_buf = erealloc(stream_protocols_buf, stream_protocols_buf_len + stream_protocol_len + 2 + 1);
                                        memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len);
                                        stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len] = ',';
                                        stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len + 1] = ' ';
index e6cc2cf67f1b611d54839640b06d4e392a707e2c..10e3396edfa43a56387cf1d75cc10da1b3cecaf6 100644 (file)
@@ -145,9 +145,7 @@ static char Lookahead(char *word, int how_far)
  * could be one though; or more too). */
 #define Phonize(c)     { \
                                                if (p_idx >= max_buffer_len) { \
-                                                       if (NULL == (*phoned_word = erealloc(*phoned_word, max_buffer_len + 2))) { \
-                                                               return -1; \
-                                                       } \
+                                                       *phoned_word = erealloc(*phoned_word, max_buffer_len + 2); \
                                                        max_buffer_len += 2; \
                                                } \
                                                (*phoned_word)[p_idx++] = c; \
@@ -185,13 +183,9 @@ static int metaphone(char *word, int word_len, int max_phonemes, char **phoned_w
        if (max_phonemes == 0) {        /* Assume largest possible */
                max_buffer_len = word_len;
                *phoned_word = emalloc(sizeof(char) * word_len + 1);
-               if (!*phoned_word)
-                       return -1;
        } else {
                max_buffer_len = max_phonemes;
                *phoned_word = emalloc(sizeof(char) * max_phonemes + 1);
-               if (!*phoned_word)
-                       return -1;
        }
 
 
index 65b995de863dba16de2bf90311e4bb802a26821e..b6fe0f03aeb6d5bb51411fff19fa1ed96792adfb 100644 (file)
@@ -113,9 +113,6 @@ static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t *
        size_t i, j;
 
        result = (char *) emalloc(oldlen * 2 * sizeof(char) + 1);
-       if (!result) {
-               return result;
-       }
        
        for (i = j = 0; i < oldlen; i++) {
                result[j++] = hexconvtab[old[i] >> 4];