Pass write callback explicitly in prof_data

This commit is contained in:
Yinan Zhang
2020-04-20 14:09:08 -07:00
parent 4556d3c0c8
commit 1f5fe3a3e3
4 changed files with 84 additions and 54 deletions

View File

@@ -388,11 +388,6 @@ prof_dump_flush(void *cbopaque, const char *s) {
}
}
static void
prof_dump_write(const char *s) {
buf_writer_cb(&prof_dump_buf_writer, s);
}
static void
prof_dump_close() {
if (prof_dump_fd != -1) {
@@ -461,7 +456,7 @@ prof_dump_maps() {
return;
}
prof_dump_write("\nMAPPED_LIBRARIES:\n");
buf_writer_cb(&prof_dump_buf_writer, "\nMAPPED_LIBRARIES:\n");
buf_writer_pipe(&prof_dump_buf_writer, prof_dump_read_maps_cb, &mfd);
close(mfd);
}
@@ -487,7 +482,8 @@ prof_dump(tsd_t *tsd, bool propagate_err, const char *filename,
bool err = buf_writer_init(tsd_tsdn(tsd), &prof_dump_buf_writer,
prof_dump_flush, NULL, prof_dump_buf, PROF_DUMP_BUFSIZE);
assert(!err);
prof_dump_impl(tsd, tdata, prof_dump_write, leakcheck);
prof_dump_impl(tsd, buf_writer_cb, &prof_dump_buf_writer, tdata,
leakcheck);
prof_dump_maps();
buf_writer_terminate(tsd_tsdn(tsd), &prof_dump_buf_writer);
prof_dump_close();