]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Help valgrind see that there is no leak in dd.c.
authorJim Meyering <jim@meyering.net>
Thu, 16 Nov 2006 08:15:47 +0000 (09:15 +0100)
committerJim Meyering <jim@meyering.net>
Thu, 16 Nov 2006 08:15:47 +0000 (09:15 +0100)
* 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.

ChangeLog
src/dd.c

index b789d677986aa71fe573eed479f38fcd52ce9d7d..9bdf549fcb7863a2ab0ad5e0365aa9e856c1499b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-11-16  Jim Meyering  <jim@meyering.net>
+
+       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.
+
 2006-11-15  Jim Meyering  <jim@meyering.net>
 
        * .x-po-check: Exclude gl/ files.  Otherwise, po-check would
index dc71a032fdaa7a42f0af3abc68662186f2f5b1ee..f1dc47452321e19c3cd5f36477a189f58d436322 100644 (file)
--- 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)