diff options
| author | tv <tv@NetBSD.org> | 2000-07-26 00:17:09 +0000 |
|---|---|---|
| committer | tv <tv@NetBSD.org> | 2000-07-26 00:17:09 +0000 |
| commit | dc36174cbda5524f93f5b7f403e5f43dfdd98cae (patch) | |
| tree | 779f68d62a9c8fb600acae82e6aca92114174bad /gnu/dist/toolchain/gcc/java/buffer.c | |
| parent | 48b9eee5e169e02e12f31b637e0495fc0bef28e0 (diff) | |
Import of gcc 2.95.2 into new gnu/dist/toolchain layout.
Diffstat (limited to 'gnu/dist/toolchain/gcc/java/buffer.c')
| -rw-r--r-- | gnu/dist/toolchain/gcc/java/buffer.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gnu/dist/toolchain/gcc/java/buffer.c b/gnu/dist/toolchain/gcc/java/buffer.c new file mode 100644 index 00000000000..67dad18a5dc --- /dev/null +++ b/gnu/dist/toolchain/gcc/java/buffer.c @@ -0,0 +1,52 @@ +/* A "buffer" utility type. + Copyright (C) 1998 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +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. + +GNU CC is distributed in the hope that it will be useful, +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 +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Written by Per Bothner <bothner@cygnus.com>, July 1998. */ + +#include "config.h" +#include "system.h" +#include "gansidecl.h" +#include "buffer.h" + +/* Grow BUFP so there is room for at least SIZE more bytes. */ + +void +buffer_grow (bufp, size) + struct buffer *bufp; + int size; +{ + if (bufp->limit - bufp->ptr >= size) + return; + if (bufp->data == 0) + { + if (size < 120) + size = 120; + bufp->data = (unsigned char*) xmalloc (size); + bufp->ptr = bufp->data; + } + else + { + int index = bufp->ptr - bufp->data; + size += 2 * (bufp->limit - bufp->data); + bufp->data = (unsigned char *) xrealloc (bufp->data, size); + bufp->ptr = bufp->data + index; + } + bufp->limit = bufp->data + size; +} |
