pike.git / src / modules / _Stdio / file.c

version» Context lines:

pike.git/src/modules/_Stdio/file.c:739:    return ret;   }      static struct pike_string *do_read(int fd,    INT32 r,    int all,    INT_TYPE *err)   {    size_t bytes = r;    struct byte_buffer buf = BUFFER_INIT(); -  int e = 0, nomem = 0; +  int e = 0;       THREADS_ALLOW();       while (bytes) {    size_t len = MINIMUM(DIRECT_BUFSIZE, bytes);    ptrdiff_t i;    -  if (UNLIKELY(!buffer_ensure_space_nothrow(&buf, len))) { +  /* make space for exactly len bytes plus the terminating null byte */ +  if (UNLIKELY(!buffer_make_space_nothrow(&buf, len+1))) {    buffer_free(&buf);    e = ENOMEM;    break;    }       i = fd_read(fd, buffer_alloc_unsafe(&buf, len), len);       if (LIKELY(i >= 0)) {    if ((size_t)i < len) buffer_remove(&buf, len - i);    bytes -= i;