tools lib traceevent: Add trace_seq_reset()
authorNamhyung Kim <[email protected]>
Tue, 4 Jun 2013 05:20:19 +0000 (14:20 +0900)
committerArnaldo Carvalho de Melo <[email protected]>
Fri, 12 Jul 2013 16:52:12 +0000 (13:52 -0300)
Sometimes it'd be useful if existing trace_seq can be reused.  But
currently it's impossible since there's no API to reset the trace_seq.
Let's add trace_seq_reset() for this case.

Signed-off-by: Namhyung Kim <[email protected]>
Acked-by: Steven Rostedt <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/lib/traceevent/event-parse.h
tools/lib/traceevent/trace-seq.c

index bfceab948f22ec1fc16e9885b23436958fa7b037..39f0c1dca91578a7cd414be6cc96a500bdd1d235 100644 (file)
@@ -69,6 +69,7 @@ struct trace_seq {
 };
 
 void trace_seq_init(struct trace_seq *s);
+void trace_seq_reset(struct trace_seq *s);
 void trace_seq_destroy(struct trace_seq *s);
 
 extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
index a57db805136a2c205c6284d65045c2cbd5ee471d..d7f2e68bc5b91d190e2ad5cd34388b45d957372a 100644 (file)
@@ -48,6 +48,19 @@ void trace_seq_init(struct trace_seq *s)
        s->buffer = malloc_or_die(s->buffer_size);
 }
 
+/**
+ * trace_seq_reset - re-initialize the trace_seq structure
+ * @s: a pointer to the trace_seq structure to reset
+ */
+void trace_seq_reset(struct trace_seq *s)
+{
+       if (!s)
+               return;
+       TRACE_SEQ_CHECK(s);
+       s->len = 0;
+       s->readpos = 0;
+}
+
 /**
  * trace_seq_destroy - free up memory of a trace_seq
  * @s: a pointer to the trace_seq to free the buffer