buffer.h 1.4 KB
Newer Older
Anthony Green committed
1
/* A "buffer" utility type.
2
   Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
Anthony Green committed
3

4
This file is part of GCC.
Anthony Green committed
5

6
GCC is free software; you can redistribute it and/or modify
Anthony Green committed
7 8 9 10
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

11
GCC is distributed in the hope that it will be useful,
Anthony Green committed
12 13 14 15 16
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
17
along with GCC; see the file COPYING.  If not, write to
Anthony Green committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */

/* Written by Per Bothner <bothner@cygnus.com>, July 1998. */

/* A simple data structure for an expandable buffer. */

struct buffer
{
  /* The start of the actual data buffer. */
  unsigned char *data;

  /* Where to write next in the buffer. */
  unsigned char *ptr;

  /* The end of the allocated data buffer. */
  unsigned char *limit;
};

#define NULL_BUFFER { (void*) 0, (void*) 0, (void*) 0 }

Per Bothner committed
39 40 41
#define BUFFER_INIT(BUFP) \
  ((BUFP)->data = NULL, (BUFP)->ptr = NULL, (BUFP)->limit = NULL)

Anthony Green committed
42 43 44 45
#define BUFFER_LENGTH(BUFP) ((BUFP)->ptr - (BUFP)->data)

#define BUFFER_RESET(BUFP) ((BUFP)->ptr = (BUFP)->data)

46
extern void buffer_grow (struct buffer*, int);