aboutsummaryrefslogtreecommitdiffstats
path: root/trace-input.c
diff options
context:
space:
mode:
Diffstat (limited to 'trace-input.c')
-rw-r--r--trace-input.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/trace-input.c b/trace-input.c
index db48c91..72a604e 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -518,6 +518,13 @@ static void free_page(struct tracecmd_input *handle, int cpu)
518 handle->cpu_data[cpu].page = NULL; 518 handle->cpu_data[cpu].page = NULL;
519} 519}
520 520
521static void free_read_page(struct tracecmd_input *handle, int cpu)
522{
523 free_page(handle, cpu);
524 if (handle->read_page)
525 free(handle->cpu_data[cpu].read_page);
526}
527
521/* 528/*
522 * Page is mapped, now read in the page header info. 529 * Page is mapped, now read in the page header info.
523 */ 530 */
@@ -1485,8 +1492,17 @@ struct tracecmd_input *tracecmd_open(const char *file)
1485 1492
1486void tracecmd_close(struct tracecmd_input *handle) 1493void tracecmd_close(struct tracecmd_input *handle)
1487{ 1494{
1488 /* TODO FREE EVERYTHING!!! %%%% MEMORY LEAK!!! %%%% */ 1495 int cpu;
1496
1497 if (!handle)
1498 return;
1499
1500 for (cpu = 0; cpu < handle->cpus; cpu++)
1501 free_read_page(handle, cpu);
1502 free(handle->cpu_data);
1503
1489 close(handle->fd); 1504 close(handle->fd);
1505 pevent_free(handle->pevent);
1490 free(handle); 1506 free(handle);
1491} 1507}
1492 1508