[ltt-dev] [BABELTRACE PATCH] Handler function to extract string from fields

Julien Desfossez julien.desfossez at polymtl.ca
Wed Nov 23 13:19:03 EST 2011


Following the same principle as get_char_array and get_(un)signed_int,
this function returns a char* to a string from an event field.

Signed-off-by: Julien Desfossez <julien.desfossez at polymtl.ca>
---
 types/string.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/types/string.c b/types/string.c
index 9eaa9df..bff569d 100644
--- a/types/string.c
+++ b/types/string.c
@@ -99,3 +99,13 @@ void _string_definition_free(struct definition *definition)
 	g_free(string->value);
 	g_free(string);
 }
+
+char *get_string(struct definition *field)
+{
+	struct definition_string *string_definition =
+		container_of(field, struct definition_string, p);
+
+	assert(string_definition->value != NULL);
+
+	return string_definition->value;
+}
-- 
1.7.7.1





More information about the lttng-dev mailing list