Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1364 from WalterBright/fix14926
Browse files Browse the repository at this point in the history
fix Issue 14926 - Programs compiled using dmd 2.068 are generating dummy profilegc.log files
  • Loading branch information
yebblies committed Aug 29, 2015
2 parents 5fd779b + 146469c commit 5db7352
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/rt/profilegc.d
Expand Up @@ -130,21 +130,24 @@ shared static ~this()
++i;
}

qsort(counts.ptr, counts.length, Result.sizeof, &Result.qsort_cmp);

FILE* fp = logfilename.length == 0 ? stdout : fopen(logfilename.ptr, "w");
if (fp)
if (counts.length)
{
fprintf(fp, "bytes allocated, type, function, file:line\n");
foreach (ref c; counts)
qsort(counts.ptr, counts.length, Result.sizeof, &Result.qsort_cmp);

FILE* fp = logfilename.length == 0 ? stdout : fopen(logfilename.ptr, "w");
if (fp)
{
fprintf(fp, "%8llu\t%8.*s\n", cast(ulong)c.count, c.name.length, c.name.ptr);
fprintf(fp, "bytes allocated, type, function, file:line\n");
foreach (ref c; counts)
{
fprintf(fp, "%8llu\t%8.*s\n", cast(ulong)c.count, c.name.length, c.name.ptr);
}
if (logfilename.length)
fclose(fp);
}
if (logfilename.length)
fclose(fp);
else
fprintf(stderr, "cannot write profilegc log file '%.*s'", logfilename.length, logfilename.ptr);
}
else
fprintf(stderr, "cannot write profilegc log file '%.*s'", logfilename.length, logfilename.ptr);
}


0 comments on commit 5db7352

Please sign in to comment.