diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-12-15 15:26:32 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-15 15:27:07 -0500 |
commit | 81661489891908d64e1577c405cf2015de17d11d (patch) | |
tree | 9b3493c40d6b92c6034131802d535d8e7cd32e69 | |
parent | 23d149bde3a1020cf8d10da7255d080d0cf7355f (diff) |
Add free_record() to use to free records read
This adds a wrapper for freeing the records.
It also fixes a comment in tracecmd_peek_data, where
the record returned must not be freed.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-cmd.h | 5 | ||||
-rw-r--r-- | trace-input.c | 6 | ||||
-rw-r--r-- | trace-read.c | 10 |
3 files changed, 13 insertions, 8 deletions
diff --git a/trace-cmd.h b/trace-cmd.h index e67cdef..d6e4db0 100644 --- a/trace-cmd.h +++ b/trace-cmd.h | |||
@@ -36,6 +36,11 @@ struct record { | |||
36 | void *data; | 36 | void *data; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static inline void free_record(struct record *record) | ||
40 | { | ||
41 | free(record); | ||
42 | } | ||
43 | |||
39 | struct tracecmd_input; | 44 | struct tracecmd_input; |
40 | struct tracecmd_output; | 45 | struct tracecmd_output; |
41 | struct tracecmd_recorder; | 46 | struct tracecmd_recorder; |
diff --git a/trace-input.c b/trace-input.c index 3889f66..d6fc93e 100644 --- a/trace-input.c +++ b/trace-input.c | |||
@@ -734,10 +734,10 @@ read_event(struct tracecmd_input *handle, unsigned long long offset, | |||
734 | 734 | ||
735 | do { | 735 | do { |
736 | if (record) | 736 | if (record) |
737 | free(record); | 737 | free_record(record); |
738 | /* Make sure peek returns new data */ | 738 | /* Make sure peek returns new data */ |
739 | if (handle->cpu_data[cpu].next) { | 739 | if (handle->cpu_data[cpu].next) { |
740 | free(handle->cpu_data[cpu].next); | 740 | free_record(handle->cpu_data[cpu].next); |
741 | handle->cpu_data[cpu].next = NULL; | 741 | handle->cpu_data[cpu].next = NULL; |
742 | } | 742 | } |
743 | record = tracecmd_read_data(handle, cpu); | 743 | record = tracecmd_read_data(handle, cpu); |
@@ -1054,7 +1054,7 @@ tracecmd_translate_data(struct tracecmd_input *handle, | |||
1054 | * This returns the record at the current location of the CPU | 1054 | * This returns the record at the current location of the CPU |
1055 | * iterator. It does not increment the CPU iterator. | 1055 | * iterator. It does not increment the CPU iterator. |
1056 | * | 1056 | * |
1057 | * The record returned must be freed. | 1057 | * NOTE: Do not free the record returned, it is stored in the @handle. |
1058 | */ | 1058 | */ |
1059 | struct record * | 1059 | struct record * |
1060 | tracecmd_peek_data(struct tracecmd_input *handle, int cpu) | 1060 | tracecmd_peek_data(struct tracecmd_input *handle, int cpu) |
diff --git a/trace-read.c b/trace-read.c index da5b0bf..b6b233c 100644 --- a/trace-read.c +++ b/trace-read.c | |||
@@ -72,7 +72,7 @@ static void show_test(struct tracecmd_input *handle) | |||
72 | trace_seq_do_printf(&s); | 72 | trace_seq_do_printf(&s); |
73 | printf("\n"); | 73 | printf("\n"); |
74 | 74 | ||
75 | free(record); | 75 | free_record(record); |
76 | } | 76 | } |
77 | 77 | ||
78 | static void test_save(struct record *record, int cpu) | 78 | static void test_save(struct record *record, int cpu) |
@@ -118,7 +118,7 @@ static void show_test(struct tracecmd_input *handle) | |||
118 | trace_seq_do_printf(&s); | 118 | trace_seq_do_printf(&s); |
119 | printf("\n"); | 119 | printf("\n"); |
120 | 120 | ||
121 | free(record); | 121 | free_record(record); |
122 | } | 122 | } |
123 | 123 | ||
124 | static void test_save(struct record *record, int cpu) | 124 | static void test_save(struct record *record, int cpu) |
@@ -158,7 +158,7 @@ static void show_test(struct tracecmd_input *handle) | |||
158 | trace_seq_do_printf(&s); | 158 | trace_seq_do_printf(&s); |
159 | printf("\n"); | 159 | printf("\n"); |
160 | 160 | ||
161 | free(record); | 161 | free_record(record); |
162 | 162 | ||
163 | record = tracecmd_read_cpu_last(handle, cpu); | 163 | record = tracecmd_read_cpu_last(handle, cpu); |
164 | if (!record) { | 164 | if (!record) { |
@@ -173,7 +173,7 @@ static void show_test(struct tracecmd_input *handle) | |||
173 | trace_seq_do_printf(&s); | 173 | trace_seq_do_printf(&s); |
174 | printf("\n"); | 174 | printf("\n"); |
175 | 175 | ||
176 | free(record); | 176 | free_record(record); |
177 | } | 177 | } |
178 | static void test_save(struct record *record, int cpu) | 178 | static void test_save(struct record *record, int cpu) |
179 | { | 179 | { |
@@ -206,7 +206,7 @@ static void show_data(struct tracecmd_input *handle, int cpu) | |||
206 | trace_seq_do_printf(&s); | 206 | trace_seq_do_printf(&s); |
207 | printf("\n"); | 207 | printf("\n"); |
208 | 208 | ||
209 | free(record); | 209 | free_record(record); |
210 | } | 210 | } |
211 | 211 | ||
212 | static void read_rest(void) | 212 | static void read_rest(void) |