Back to index

glibc  2.9
Defines | Functions
filedoalloc.c File Reference
#include "libioP.h"
#include <sys/types.h>
#include <sys/stat.h>

Go to the source code of this file.




int _IO_file_doallocate (_IO_FILE *fp)

Define Documentation


Definition at line 60 of file filedoalloc.c.

Function Documentation

Definition at line 86 of file filedoalloc.c.

  _IO_size_t size;
  char *p;
  struct _G_stat64 st;

#ifndef _LIBC
  /* If _IO_cleanup_registration_needed is non-zero, we should call the
     function it points to.  This is to make sure _IO_cleanup gets called
     on exit.  We call it from _IO_file_doallocate, since that is likely
     to get called by any program that does buffered I/O. */
  if (__builtin_expect (_IO_cleanup_registration_needed != NULL, 0))
    (*_IO_cleanup_registration_needed) ();

  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) ||
             isatty (fp->_fileno))
           fp->_flags |= _IO_LINE_BUF;
      if (st.st_blksize > 0)
       size = st.st_blksize;
  ALLOC_BUF (p, size, EOF);
  INTUSE(_IO_setb) (fp, p, p + size, 1);
  return 1;

Here is the call graph for this function:

Here is the caller graph for this function: