VirtualBox

Changeset 24 in kBuild for branches/FREEBSD/src/kmk/buf.c


Ignore:
Timestamp:
Nov 26, 2002 9:24:54 PM (22 years ago)
Author:
bird
Message:

Import of RELENG_4_7_0_RELEASE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FREEBSD/src/kmk/buf.c

    r10 r24  
    11/*
    2  * Copyright (c) 1988, 1989, 1990, 1993
    3  *      The Regents of the University of California.  All rights reserved.
     2 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
    43 * Copyright (c) 1988, 1989 by Adam de Boor
    54 * Copyright (c) 1989 by Berkeley Softworks
     
    3635 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3736 * SUCH DAMAGE.
    38  *
    39  * @(#)buf.c    8.1 (Berkeley) 6/6/93
    40  */
    41 
    42 #include <sys/cdefs.h>
    43 __FBSDID("$FreeBSD: src/usr.bin/make/buf.c,v 1.18 2002/10/09 03:42:09 jmallett Exp $");
     37 */
     38
     39#ifndef lint
     40#if 0
     41static char sccsid[] = "@(#)buf.c       8.1 (Berkeley) 6/6/93";
     42#else
     43static const char rcsid[] =
     44  "$FreeBSD: src/usr.bin/make/buf.c,v 1.11 1999/09/11 13:08:01 hoek Exp $";
     45#endif
     46#endif /* not lint */
    4447
    4548/*-
     
    5356
    5457#ifndef max
    55 #define max(a,b)  ((a) > (b) ? (a) : (b))
     58#define max(a,b)  ((a) > (b) ? (a) : (b))
    5659#endif
    5760
     
    6366 *      buffer in case it holds a string.
    6467 */
    65 #define BufExpand(bp,nb) \
     68#define BufExpand(bp,nb) \
    6669        if (bp->left < (nb)+1) {\
    6770            int newSize = (bp)->size + max((nb)+1,BUF_ADD_INC); \
     
    7578        }
    7679
    77 #define BUF_DEF_SIZE    256     /* Default buffer size */
    78 #define BUF_ADD_INC     256     /* Expansion increment when Adding */
    79 #define BUF_UNGET_INC   16      /* Expansion increment when Ungetting */
     80#define BUF_DEF_SIZE    256     /* Default buffer size */
     81#define BUF_ADD_INC     256     /* Expansion increment when Adding */
     82#define BUF_UNGET_INC   16      /* Expansion increment when Ungetting */
    8083
    8184/*-
     
    9396 */
    9497void
    95 Buf_OvAddByte (Buffer bp, int byte)
    96 {
     98Buf_OvAddByte (bp, byte)
     99    register Buffer bp;
     100    int    byte;
     101{
     102    int nbytes = 1;
    97103    bp->left = 0;
    98     BufExpand (bp, 1);
     104    BufExpand (bp, nbytes);
    99105
    100106    *bp->inPtr++ = byte;
     
    122128 */
    123129void
    124 Buf_AddBytes (Buffer bp, int numBytes, const Byte *bytesPtr)
     130Buf_AddBytes (bp, numBytes, bytesPtr)
     131    register Buffer bp;
     132    int     numBytes;
     133    const Byte *bytesPtr;
    125134{
    126135
     
    152161 */
    153162void
    154 Buf_UngetByte (Buffer bp, int byte)
     163Buf_UngetByte (bp, byte)
     164    register Buffer bp;
     165    int    byte;
    155166{
    156167
     
    201212 */
    202213void
    203 Buf_UngetBytes (Buffer bp, int numBytes, Byte *bytesPtr)
     214Buf_UngetBytes (bp, numBytes, bytesPtr)
     215    register Buffer bp;
     216    int     numBytes;
     217    Byte    *bytesPtr;
    204218{
    205219
     
    244258 */
    245259int
    246 Buf_GetByte (Buffer bp)
     260Buf_GetByte (bp)
     261    register Buffer bp;
    247262{
    248263    int     res;
     
    277292 */
    278293int
    279 Buf_GetBytes (Buffer bp, int numBytes, Byte *bytesPtr)
     294Buf_GetBytes (bp, numBytes, bytesPtr)
     295    register Buffer bp;
     296    int     numBytes;
     297    Byte    *bytesPtr;
    280298{
    281299
     
    309327 */
    310328Byte *
    311 Buf_GetAll (Buffer bp, int *numBytesPtr)
     329Buf_GetAll (bp, numBytesPtr)
     330    register Buffer bp;
     331    int     *numBytesPtr;
    312332{
    313333
     
    334354 */
    335355void
    336 Buf_Discard (Buffer bp, int numBytes)
     356Buf_Discard (bp, numBytes)
     357    register Buffer bp;
     358    int     numBytes;
    337359{
    338360
     
    362384 */
    363385int
    364 Buf_Size (Buffer buf)
     386Buf_Size (buf)
     387    Buffer  buf;
    365388{
    366389    return (buf->inPtr - buf->outPtr);
     
    384407 */
    385408Buffer
    386 Buf_Init (int size)
     409Buf_Init (size)
     410    int     size;       /* Initial size for the buffer */
    387411{
    388412    Buffer bp;          /* New Buffer */
     
    405429 *-----------------------------------------------------------------------
    406430 * Buf_Destroy --
    407  *      Destroy a buffer, and optionally free its data, too.
     431 *      Nuke a buffer and all its resources.
    408432 *
    409433 * Results:
     
    416440 */
    417441void
    418 Buf_Destroy (Buffer buf, Boolean freeData)
     442Buf_Destroy (buf, freeData)
     443    Buffer  buf;        /* Buffer to destroy */
     444    Boolean freeData;   /* TRUE if the data should be destroyed as well */
    419445{
    420446
     
    441467 */
    442468void
    443 Buf_ReplaceLastByte (Buffer buf, int byte)
     469Buf_ReplaceLastByte (buf, byte)
     470    Buffer buf; /* buffer to augment */
     471    int byte;   /* byte to be written */
    444472{
    445473    if (buf->inPtr == buf->outPtr)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette