summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2005-03-07 21:28:38 +0000
committerMarcus Boerger <helly@php.net>2005-03-07 21:28:38 +0000
commit85ebbd28a0fded63c8ffa1770b22a7ce5999f987 (patch)
tree72c902b892ce3046bf92bd77a70b37df8e0febf3
parent975ff6f5d56bab8898bcdef1dddd0fb795a60619 (diff)
downloadphp-git-85ebbd28a0fded63c8ffa1770b22a7ce5999f987.tar.gz
- Delay memory allocation, speeds up faiure case
-rw-r--r--ext/standard/file.c7
1 files changed, 2 insertions, 5 deletions
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);
}
}
/* }}} */