Lines Matching refs:buf

49 static size_t zend_stream_stdio_reader(void *handle, char *buf, size_t len) /* {{{ */  in zend_stream_stdio_reader()  argument
51 return fread(buf, 1, len, (FILE*)handle); in zend_stream_stdio_reader()
63 zend_stat_t buf; in zend_stream_stdio_fsizer() local
64 if (handle && zend_fstat(fileno((FILE*)handle), &buf) == 0) { in zend_stream_stdio_fsizer()
66 if (!S_ISREG(buf.st_mode)) { in zend_stream_stdio_fsizer()
70 return buf.st_size; in zend_stream_stdio_fsizer()
81 if (stream->mmap.buf) { in zend_stream_unmap()
82 efree(stream->mmap.buf); in zend_stream_unmap()
87 stream->mmap.buf = 0; in zend_stream_unmap()
105 zend_stat_t buf; in zend_stream_fsize() local
113 if (file_handle->handle.fp && zend_fstat(fileno(file_handle->handle.fp), &buf) == 0) { in zend_stream_fsize()
115 if (!S_ISREG(buf.st_mode)) { in zend_stream_fsize()
119 return buf.st_size; in zend_stream_fsize()
142 char buf; in zend_stream_getc() local
144 if (file_handle->handle.stream.reader(file_handle->handle.stream.handle, &buf, sizeof(buf))) { in zend_stream_getc()
145 return (int)buf; in zend_stream_getc()
150 static size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t len) /* {{{ */ in zend_stream_read() argument
157 buf[n] = (char)c; in zend_stream_read()
160 buf[n++] = (char)c; in zend_stream_read()
165 return file_handle->handle.stream.reader(file_handle->handle.stream.handle, buf, len); in zend_stream_read()
168 ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len) /* {{{ */ in zend_stream_fixup() argument
201 *buf = file_handle->handle.stream.mmap.buf; in zend_stream_fixup()
225 … *buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0); in zend_stream_fixup()
226 if (*buf != MAP_FAILED) { in zend_stream_fixup()
228 file_handle->handle.stream.mmap.map = *buf; in zend_stream_fixup()
231 *buf += offset; in zend_stream_fixup()
234 file_handle->handle.stream.mmap.buf = *buf; in zend_stream_fixup()
242 file_handle->handle.stream.mmap.buf = *buf = safe_emalloc(1, size, ZEND_MMAP_AHEAD); in zend_stream_fixup()
243 file_handle->handle.stream.mmap.len = zend_stream_read(file_handle, *buf, size); in zend_stream_fixup()
246 *buf = emalloc(remain); in zend_stream_fixup()
249 while ((read = zend_stream_read(file_handle, *buf + size, remain)) > 0) { in zend_stream_fixup()
254 *buf = safe_erealloc(*buf, size, 2, 0); in zend_stream_fixup()
261 *buf = safe_erealloc(*buf, size, 1, ZEND_MMAP_AHEAD); in zend_stream_fixup()
263 file_handle->handle.stream.mmap.buf = *buf; in zend_stream_fixup()
267 *buf = erealloc(*buf, ZEND_MMAP_AHEAD); in zend_stream_fixup()
268 file_handle->handle.stream.mmap.buf = *buf; in zend_stream_fixup()
272 …memset(file_handle->handle.stream.mmap.buf + file_handle->handle.stream.mmap.len, 0, ZEND_MMAP_AHE… in zend_stream_fixup()
284 *buf = file_handle->handle.stream.mmap.buf; in zend_stream_fixup()