]> granicus.if.org Git - php/commitdiff
- Delay memory allocation, speeds up faiure case
authorMarcus Boerger <helly@php.net>
Mon, 7 Mar 2005 21:28:38 +0000 (21:28 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 7 Mar 2005 21:28:38 +0000 (21:28 +0000)
ext/standard/file.c

index 31121cf2b44daca2de00fa0c7e4e6ddae6698f49..f1d283f106ac4bbda42b47cef384413b55d419a2 100644 (file)
@@ -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);
        }
 }
 /* }}} */