]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Truncate the cachegrind.out.<pid> file, if it already exists. It wasn't doing
authorNicholas Nethercote <njn@valgrind.org>
Tue, 22 Jul 2003 20:45:11 +0000 (20:45 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Tue, 22 Jul 2003 20:45:11 +0000 (20:45 +0000)
this, which meant that if a shorter file of the same name was written, the old
contents past the new end would remain, which would be bad.  Had (probably)
never happened because the <pid> suffix makes it very unlikely for filenames to
be reused.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1777

cachegrind/cg_main.c

index 80f853e3b3753a495eaec9431c882606c3aa16c2..e378501e0459fbffc94ef78a94722511a7f1ba18 100644 (file)
@@ -1529,7 +1529,7 @@ static void fprint_BBCC_table_and_calc_totals(void)
 
    VGP_PUSHCC(VgpCacheResults);
 
-   fd = VG_(open)(cachegrind_out_file, VKI_O_CREAT|VKI_O_WRONLY,
+   fd = VG_(open)(cachegrind_out_file, VKI_O_CREAT|VKI_O_TRUNC|VKI_O_WRONLY,
                                        VKI_S_IRUSR|VKI_S_IWUSR);
    if (-1 == fd) {
       /* If the file can't be opened for whatever reason (conflict