monkeyDluffy6017 commented on issue #7839:
URL: https://github.com/apache/apisix/issues/7839#issuecomment-1240561174

   ```
   /* Allocate a file buffer, or switch to unbuffered I/O.  Streams for
      TTY devices default to line buffered.  */
   int
   _IO_file_doallocate (_IO_FILE *fp)
   {
     _IO_size_t size;
     char *p;
     struct stat64 st;
   
     size = _IO_BUFSIZ;
     if (fp->_fileno >= 0 && __builtin_expect (_IO_SYSSTAT (fp, &st), 0) >= 0)
       {
         if (S_ISCHR (st.st_mode))
        {
          /* Possibly a tty.  */
          if (
   #ifdef DEV_TTY_P
              DEV_TTY_P (&st) ||
   #endif
              local_isatty (fp->_fileno))
            fp->_flags |= _IO_LINE_BUF;
        }
   #if _IO_HAVE_ST_BLKSIZE
         if (st.st_blksize > 0 && st.st_blksize < _IO_BUFSIZ)
        size = st.st_blksize;
   #endif
       }
     p = malloc (size);
     if (__glibc_unlikely (p == NULL))
       return EOF;
     _IO_setb (fp, p, p + size, 1);
     return 1;
   }
   ```
   From the glibc code, we know that the default vary from files and os, it's 
default size depend on macro `BUFSIZ`, the `BUFSIZ` is different on different 
os, and if the file is smaller than the `BUFSIZ`, it will just allocate the 
size of the file.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to