Module Name: src
Committed By: rillig
Date: Sat Jan 30 20:59:29 UTC 2021
Modified Files:
src/usr.bin/make: buf.c
Log Message:
make(1): only clean up the Buffer data in CLEANUP mode
Cleaning up the members is only useful during debugging but not during
use in production.
To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/make/buf.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/buf.c
diff -u src/usr.bin/make/buf.c:1.48 src/usr.bin/make/buf.c:1.49
--- src/usr.bin/make/buf.c:1.48 Sat Jan 30 20:53:29 2021
+++ src/usr.bin/make/buf.c Sat Jan 30 20:59:29 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.c,v 1.48 2021/01/30 20:53:29 rillig Exp $ */
+/* $NetBSD: buf.c,v 1.49 2021/01/30 20:59:29 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.48 2021/01/30 20:53:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: buf.c,v 1.49 2021/01/30 20:59:29 rillig Exp $");
/* Make space in the buffer for adding at least 16 more bytes. */
void
@@ -176,30 +176,34 @@ Buf_Init(Buffer *buf)
/*
* Free the data from the buffer.
- * The buffer is left in an indeterminate state.
+ * Leave the buffer itself in an indeterminate state.
*/
void
Buf_Done(Buffer *buf)
{
free(buf->data);
+#ifdef CLEANUP
buf->cap = 0;
buf->len = 0;
buf->data = NULL;
+#endif
}
/*
* Return the data from the buffer.
- * The buffer is left in an indeterminate state.
+ * Leave the buffer itself in an indeterminate state.
*/
char *
Buf_DoneData(Buffer *buf)
{
char *data = buf->data;
+#ifdef CLEANUP
buf->cap = 0;
buf->len = 0;
buf->data = NULL;
+#endif
return data;
}
@@ -209,7 +213,8 @@ Buf_DoneData(Buffer *buf)
#endif
/*
- * Reset the buffer and return its data.
+ * Return the data from the buffer.
+ * Leave the buffer itself in an indeterminate state.
*
* If the buffer size is much greater than its content,
* a new buffer will be allocated and the old one freed.