diff options
Diffstat (limited to 'contrib/bmake/buf.h')
-rw-r--r-- | contrib/bmake/buf.h | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/contrib/bmake/buf.h b/contrib/bmake/buf.h index 938820e4745f..c5e7d539de9e 100644 --- a/contrib/bmake/buf.h +++ b/contrib/bmake/buf.h @@ -1,4 +1,4 @@ -/* $NetBSD: buf.h,v 1.43 2021/04/03 11:08:40 rillig Exp $ */ +/* $NetBSD: buf.h,v 1.49 2023/12/19 19:33:39 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -88,7 +88,15 @@ typedef struct Buffer { void Buf_Expand(Buffer *); -/* Buf_AddByte adds a single byte to a buffer. */ +/* Mark the buffer as empty, so it can be filled with data again. */ +MAKE_INLINE void +Buf_Clear(Buffer *buf) +{ + buf->len = 0; + buf->data[0] = '\0'; +} + +/* Adds a single byte to a buffer. */ MAKE_INLINE void Buf_AddByte(Buffer *buf, char byte) { @@ -101,21 +109,21 @@ Buf_AddByte(Buffer *buf, char byte) end[1] = '\0'; } -MAKE_INLINE bool +MAKE_INLINE bool MAKE_ATTR_USE Buf_EndsWith(const Buffer *buf, char ch) { return buf->len > 0 && buf->data[buf->len - 1] == ch; } void Buf_AddBytes(Buffer *, const char *, size_t); -void Buf_AddBytesBetween(Buffer *, const char *, const char *); +void Buf_AddRange(Buffer *, const char *, const char *); void Buf_AddStr(Buffer *, const char *); void Buf_AddInt(Buffer *, int); -void Buf_Empty(Buffer *); +void Buf_AddFlag(Buffer *, bool, const char *); void Buf_Init(Buffer *); void Buf_InitSize(Buffer *, size_t); void Buf_Done(Buffer *); -char *Buf_DoneData(Buffer *); -char *Buf_DoneDataCompact(Buffer *); +char *Buf_DoneData(Buffer *) MAKE_ATTR_USE; +char *Buf_DoneDataCompact(Buffer *) MAKE_ATTR_USE; -#endif /* MAKE_BUF_H */ +#endif |