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

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Mon Nov 28 09:26:28 EST 2011


I guess you forgot to add the header prototype. I did it for you. Merged
as:

commit 98b6832656447ab0f8024f9086aa67625e391ac7
Author: Julien Desfossez <julien.desfossez at polymtl.ca>
Date:   Mon Nov 28 09:24:37 2011 -0500

    Helper function to extract string from fields
    
    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.
    
    [ Edit by Mathieu Desnoyers: add header prototype. ]
    
    Signed-off-by: Julien Desfossez <julien.desfossez at polymtl.ca>
    Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>

diff --git a/include/babeltrace/types.h b/include/babeltrace/types.h
index 41f7038..f3a0e83 100644
--- a/include/babeltrace/types.h
+++ b/include/babeltrace/types.h
@@ -431,6 +431,7 @@ struct declaration_enum *
 
 struct declaration_string *
 	string_declaration_new(enum ctf_string_encoding encoding);
+char *get_string(struct definition *field);
 
 struct declaration_struct *
 	struct_declaration_new(struct declaration_scope *parent_scope,
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;
+}

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list