summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/buf.c
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-03-08 13:15:18 +0000
committerharti <harti@FreeBSD.org>2005-03-08 13:15:18 +0000
commitd8085e2228d73b5f739f8546bc093b3fed1b025a (patch)
tree31966ccde7fef1114727ad4660f3e8229afdc2e3 /usr.bin/make/buf.c
parent891dde82bd19fff801fb7e2e091e6605938fa94f (diff)
downloadFreeBSD-src-d8085e2228d73b5f739f8546bc093b3fed1b025a.zip
FreeBSD-src-d8085e2228d73b5f739f8546bc093b3fed1b025a.tar.gz
Create a new function Buf_Peel that returns the string from inside
a Buffer and frees the Buffer.
Diffstat (limited to 'usr.bin/make/buf.c')
-rw-r--r--usr.bin/make/buf.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c
index dc19282..0da71e7 100644
--- a/usr.bin/make/buf.c
+++ b/usr.bin/make/buf.c
@@ -136,6 +136,25 @@ Buf_GetAll(Buffer *bp, size_t *len)
}
/**
+ * Get the contents of a buffer and destroy the buffer. If the buffer
+ * is NULL, return NULL.
+ *
+ * Returns:
+ * the pointer to the data.
+ */
+char *
+Buf_Peel(Buffer *bp)
+{
+ char *ret;
+
+ if (bp == NULL)
+ return (NULL);
+ ret = bp->buf;
+ free(bp);
+ return (ret);
+}
+
+/**
* Initialize a buffer. If no initial size is given, a reasonable
* default is used.
*
OpenPOWER on IntegriCloud