OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [newlib/] [libc/] [stdio/] [setvbuf.c] - Diff between revs 39 and 56

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 39 Rev 56
Line 1... Line 1...
 
 
/*
/*
 * Copyright (c) 1990 The Regents of the University of California.
 * Copyright (c) 1990 The Regents of the University of California.
 * All rights reserved.
 * All rights reserved.
 *
 *
 * Redistribution and use in source and binary forms are permitted
 * Redistribution and use in source and binary forms are permitted
Line 111... Line 112...
   */
   */
 
 
  if ((mode != _IOFBF && mode != _IOLBF && mode != _IONBF) || (int)(_POINTER_INT) size < 0)
  if ((mode != _IOFBF && mode != _IOLBF && mode != _IONBF) || (int)(_POINTER_INT) size < 0)
    return (EOF);
    return (EOF);
 
 
  if (mode == _IONBF)
 
    goto nbf;
 
 
 
  /*
  /*
   * Write current buffer, if any; drop read count, if any.
   * Write current buffer, if any; drop read count, if any.
   * Make sure putc() will not think fp is line buffered.
   * Make sure putc() will not think fp is line buffered.
   * Free old buffer if it was from malloc().  Clear line and
   * Free old buffer if it was from malloc().  Clear line and
   * non buffer flags, and clear malloc flag.
   * non buffer flags, and clear malloc flag.
Line 128... Line 126...
  fp->_lbfsize = 0;
  fp->_lbfsize = 0;
  if (fp->_flags & __SMBF)
  if (fp->_flags & __SMBF)
    _free_r (fp->_data, (void *) fp->_bf._base);
    _free_r (fp->_data, (void *) fp->_bf._base);
  fp->_flags &= ~(__SLBF | __SNBF | __SMBF);
  fp->_flags &= ~(__SLBF | __SNBF | __SMBF);
 
 
 
  if (mode == _IONBF)
 
    goto nbf;
 
 
  /*
  /*
   * Allocate buffer if needed. */
   * Allocate buffer if needed. */
  if (buf == NULL)
  if (buf == NULL)
    {
    {
      if ((buf = malloc (size)) == NULL)
      if ((buf = malloc (size)) == NULL)
        {
        {
          ret = EOF;
          ret = EOF;
          /* Try another size... */
          /* Try another size... */
          buf = malloc (BUFSIZ);
          buf = malloc (BUFSIZ);
 
          size = BUFSIZ;
        }
        }
      if (buf == NULL)
      if (buf == NULL)
        {
        {
          /* Can't allocate it, let's try another approach */
          /* Can't allocate it, let's try another approach */
nbf:
nbf:

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.