Helper function to extract string from fields
authorJulien Desfossez <julien.desfossez@polymtl.ca>
Mon, 28 Nov 2011 14:24:37 +0000 (09:24 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 28 Nov 2011 14:24:37 +0000 (09:24 -0500)
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@polymtl.ca>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/babeltrace/types.h
types/string.c

index 41f70383c254af13d1f1a8d03fbee4652f00389c..f3a0e831b15fcdfb9a85f76dc79a0c569222ca8a 100644 (file)
@@ -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,
index 9eaa9df800e25219e6d817e98c57daa2b94f4565..bff569db93bb11118b0904d48fcc5f1454623863 100644 (file)
@@ -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;
+}
This page took 0.033645 seconds and 4 git commands to generate.