summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-11-16 09:15:47 +0100
committerJim Meyering <jim@meyering.net>2006-11-16 09:15:47 +0100
commitfc9b802e3d282875e2ad4bcafa954c0ce1c759f8 (patch)
tree72a4491938790bf12d258b56000318b28f2b2c2e /src
parente189a79efd5d1d1eba8d03a84a015bbe6e53eb7f (diff)
downloadcoreutils-fc9b802e3d282875e2ad4bcafa954c0ce1c759f8.tar.xz
Help valgrind see that there is no leak in dd.c.
* src/dd.c (dd_copy): Declare real_buf and real_obuf to be static, so we need not free them at all. This is easier than freeing both buffers at each of the early "return"s.
Diffstat (limited to 'src')
-rw-r--r--src/dd.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/dd.c b/src/dd.c
index dc71a032f..f1dc47452 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -1377,8 +1377,10 @@ static int
dd_copy (void)
{
char *ibuf, *bufstart; /* Input buffer. */
- char *real_buf; /* real buffer address before alignment */
- char *real_obuf;
+ /* These are declared static so that even though we don't free the
+ buffers, valgrind will recognize that there is no "real" leak. */
+ static char *real_buf; /* real buffer address before alignment */
+ static char *real_obuf;
ssize_t nread; /* Bytes read in the current block. */
/* If nonzero, then the previously read block was partial and
@@ -1598,9 +1600,6 @@ dd_copy (void)
}
}
- free (real_buf);
- free (real_obuf);
-
if ((conversions_mask & C_FDATASYNC) && fdatasync (STDOUT_FILENO) != 0)
{
if (errno != ENOSYS && errno != EINVAL)