version 1.15, 2001/05/03 13:41:01 |
version 1.16, 2001/05/23 12:34:40 |
|
|
* Functions for automatically-expanded buffers. |
* Functions for automatically-expanded buffers. |
*/ |
*/ |
|
|
#include "sprite.h" |
#include <ctype.h> |
#include "make.h" |
#include <stddef.h> |
#include "buf.h" |
#include "config.h" |
#include "stats.h" |
#include "defines.h" |
|
#include "buf.h" |
|
#include "stats.h" |
|
#include "memory.h" |
|
|
#ifndef lint |
|
#if 0 |
|
static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93"; |
|
#else |
|
UNUSED |
|
static char rcsid[] = "$OpenBSD$"; |
|
#endif |
|
#endif /* not lint */ |
|
|
|
|
|
#ifdef STATS_BUF |
#ifdef STATS_BUF |
#define DO_STAT_BUF(bp, nb) \ |
#define DO_STAT_BUF(bp, nb) \ |
STAT_BUFS_EXPANSION++; \ |
STAT_BUFS_EXPANSION++; \ |
|
|
#define DO_STAT_BUF(a, b) |
#define DO_STAT_BUF(a, b) |
#endif |
#endif |
|
|
/* BufExpand -- |
/* BufExpand(bp, nb) |
* Expand the given buffer to hold the given number of additional |
* Expand buffer bp to hold upto nb additional |
* chars. Makes sure there's room for an extra '\0' char at |
* chars. Makes sure there's room for an extra '\0' char at |
* the end of the buffer to terminate the string. */ |
* the end of the buffer to terminate the string. */ |
#define BufExpand(bp,nb) \ |
#define BufExpand(bp,nb) \ |
|
|
#define BUF_DEF_SIZE 256 /* Default buffer size */ |
#define BUF_DEF_SIZE 256 /* Default buffer size */ |
#define BUF_MARGIN 256 /* Make sure we are comfortable */ |
#define BUF_MARGIN 256 /* Make sure we are comfortable */ |
|
|
/* Buf_AddChar hard case: buffer must be expanded to accommodate |
/* the hard case for Buf_AddChar: buffer must be expanded to accommodate |
* one more char. */ |
* one more char. */ |
void |
void |
BufOverflow(bp) |
BufOverflow(bp) |
|
|
|
|
void |
void |
Buf_Init(bp, size) |
Buf_Init(bp, size) |
Buffer bp; /* New Buffer to initialize */ |
Buffer bp; |
size_t size; /* Initial size for the buffer */ |
size_t size; |
{ |
{ |
#ifdef STATS_BUF |
#ifdef STATS_BUF |
STAT_TOTAL_BUFS++; |
STAT_TOTAL_BUFS++; |