diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2009-11-30 21:26:36 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2009-11-30 21:26:36 -0500 |
| commit | 87768022f28cf7a2e35b1bee72d7cac577c19330 (patch) | |
| tree | 6778d9a02f099918572e8fd982c747a72b3bc5fe | |
| parent | ff8045d6fe327e96065c8d87564acaac1c62a34a (diff) | |
Handle better memory management of tracecmd_read_at
The memory management of the cached record let records leak like crazy
when tracecmd_read_at was used.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-input.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/trace-input.c b/trace-input.c index 6fee129..eead50c 100644 --- a/trace-input.c +++ b/trace-input.c | |||
| @@ -593,7 +593,7 @@ static struct record * | |||
| 593 | read_event(struct tracecmd_handle *handle, unsigned long long offset, | 593 | read_event(struct tracecmd_handle *handle, unsigned long long offset, |
| 594 | int cpu) | 594 | int cpu) |
| 595 | { | 595 | { |
| 596 | struct record *record; | 596 | struct record *record = NULL; |
| 597 | 597 | ||
| 598 | /* | 598 | /* |
| 599 | * Since the timestamp is calculated from the beginnnig | 599 | * Since the timestamp is calculated from the beginnnig |
| @@ -607,8 +607,13 @@ read_event(struct tracecmd_handle *handle, unsigned long long offset, | |||
| 607 | handle->cpu_data[cpu].index = 0; | 607 | handle->cpu_data[cpu].index = 0; |
| 608 | 608 | ||
| 609 | do { | 609 | do { |
| 610 | if (record) | ||
| 611 | free(record); | ||
| 610 | /* Make sure peek returns new data */ | 612 | /* Make sure peek returns new data */ |
| 611 | handle->cpu_data[cpu].next = NULL; | 613 | if (handle->cpu_data[cpu].next) { |
| 614 | free(handle->cpu_data[cpu].next); | ||
| 615 | handle->cpu_data[cpu].next = NULL; | ||
| 616 | } | ||
| 612 | record = tracecmd_read_data(handle, cpu); | 617 | record = tracecmd_read_data(handle, cpu); |
| 613 | } while (record && (record->offset + record->record_size) <= offset); | 618 | } while (record && (record->offset + record->record_size) <= offset); |
| 614 | 619 | ||
