From: Marcus Boerger Date: Mon, 7 Mar 2005 21:28:38 +0000 (+0000) Subject: - Delay memory allocation, speeds up faiure case X-Git-Tag: RELEASE_0_3~42 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85ebbd28a0fded63c8ffa1770b22a7ce5999f987;p=php - Delay memory allocation, speeds up faiure case --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 31121cf2b4..f1d283f106 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1052,7 +1052,7 @@ exit_failed: PHPAPI PHP_FUNCTION(fgetc) { zval **arg1; - char *buf; + char buf[2]; int result; php_stream *stream; @@ -1062,18 +1062,15 @@ PHPAPI PHP_FUNCTION(fgetc) PHP_STREAM_TO_ZVAL(stream, arg1); - buf = safe_emalloc(2, sizeof(char), 0); - result = php_stream_getc(stream); if (result == EOF) { - efree(buf); RETVAL_FALSE; } else { buf[0] = result; buf[1] = '\0'; - RETURN_STRINGL(buf, 1, 0); + RETURN_STRINGL(buf, 1, 1); } } /* }}} */