public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-14] gcov: Use xstrdup()
@ 2022-04-28 19:41 Sebastian Huber
  0 siblings, 0 replies; only message in thread
From: Sebastian Huber @ 2022-04-28 19:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f9b59dd8e5586862cd3c2fa53901ee2e90226a3c

commit r13-14-gf9b59dd8e5586862cd3c2fa53901ee2e90226a3c
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date:   Wed Mar 30 21:49:51 2022 +0200

    gcov: Use xstrdup()
    
    Move duplication of filename to caller and use xstrdup() instead of custom
    code.  This helps to reuse read_gcda_file() for other purposes.
    
    libgcc/
    
            * libgcov-util.c (read_gcda_file): Do not duplicate filename.
            (ftw_read_file): Duplicate filename for read_gcda_file().

Diff:
---
 libgcc/libgcov-util.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c
index db157220c9d..ae5712c0138 100644
--- a/libgcc/libgcov-util.c
+++ b/libgcc/libgcov-util.c
@@ -296,16 +296,11 @@ read_gcda_file (const char *filename)
              sizeof (struct gcov_ctr_info) * GCOV_COUNTERS, 1);
 
   obj_info->version = version;
+  obj_info->filename = filename;
   obstack_init (&fn_info);
   num_fn_info = 0;
   curr_fn_info = 0;
-  {
-    size_t len = strlen (filename) + 1;
-    char *str_dup = (char*) xmalloc (len);
 
-    memcpy (str_dup, filename, len);
-    obj_info->filename = str_dup;
-  }
 
   /* Read stamp.  */
   obj_info->stamp = gcov_read_unsigned ();
@@ -415,7 +410,7 @@ ftw_read_file (const char *filename,
   if (verbose)
     fnotice (stderr, "reading file: %s\n", filename);
 
-  obj_info = read_gcda_file (filename);
+  obj_info = read_gcda_file (xstrdup (filename));
   if (!obj_info)
     return 0;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-28 19:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 19:41 [gcc r13-14] gcov: Use xstrdup() Sebastian Huber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).