diff options
author | Simon J. Gerraty <sjg@FreeBSD.org> | 2020-11-20 03:54:37 +0000 |
---|---|---|
committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2020-11-20 03:54:37 +0000 |
commit | 1b65f0bd2bda7121a90f8cb4c1cacaa20f1b681d (patch) | |
tree | 90c374b8513ec5109e1ec4e2228e2edf648e8756 /buf.c | |
parent | 302da1a3d35c15cb29d76e0a939f8bcb13f7ad80 (diff) | |
download | src-test2-9ea923884d3be654375c298dcc5124391ec21db5.tar.gz src-test2-9ea923884d3be654375c298dcc5124391ec21db5.zip |
Diffstat (limited to 'buf.c')
-rw-r--r-- | buf.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -1,4 +1,4 @@ -/* $NetBSD: buf.c,v 1.42 2020/10/24 20:51:49 rillig Exp $ */ +/* $NetBSD: buf.c,v 1.44 2020/11/07 14:11:58 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -75,7 +75,7 @@ #include "make.h" /* "@(#)buf.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: buf.c,v 1.42 2020/10/24 20:51:49 rillig Exp $"); +MAKE_RCSID("$NetBSD: buf.c,v 1.44 2020/11/07 14:11:58 rillig Exp $"); /* Make space in the buffer for adding a single byte. */ void @@ -155,19 +155,22 @@ Buf_Empty(Buffer *buf) buf->data[0] = '\0'; } -/* Initialize a buffer. - * If the given initial capacity is 0, a reasonable default is used. */ +/* Initialize a buffer. */ void -Buf_Init(Buffer *buf, size_t cap) +Buf_InitSize(Buffer *buf, size_t cap) { - if (cap <= 0) - cap = 256; buf->cap = cap; buf->len = 0; buf->data = bmake_malloc(cap); buf->data[0] = '\0'; } +void +Buf_Init(Buffer *buf) +{ + Buf_InitSize(buf, 256); +} + /* Reset the buffer. * If freeData is TRUE, the data from the buffer is freed as well. * Otherwise it is kept and returned. */ |