1
0
mirror of https://github.com/php/php-src.git synced 2026-04-12 18:43:37 +02:00

Make fgets not use maximal buffer length always, but shrink buffer

if it's too big.
This commit is contained in:
Stanislav Malyshev
2000-06-29 13:34:55 +00:00
parent 1f828a6e88
commit e8c219fef2

View File

@@ -990,6 +990,10 @@ PHP_FUNCTION(fgets)
} else {
return_value->value.str.val = buf;
return_value->value.str.len = strlen(return_value->value.str.val);
/* resize buffer if it's much larger than the result */
if(return_value->value.str.len < len/2) {
return_value->value.str.val = erealloc(buf,return_value->value.str.len);
}
}
return_value->type = IS_STRING;
}