}
}
+ if (maxlen > 0) {
+ ptr = *buf = pemalloc_rel_orig(maxlen + 1, persistent);
+ while ((len < maxlen) & !php_stream_eof(src)) {
+ ret = php_stream_read(src, ptr, maxlen - len);
+ len += ret;
+ ptr += ret;
+ }
+ *ptr = '\0';
+ return len;
+ }
+
/* avoid many reallocs by allocating a good sized chunk to begin with, if
* we can. Note that the stream may be filtered, in which case the stat
* result may be inaccurate, as the filter may inflate or deflate the