Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [ltt-dev] [BABELTRACE PATCH] Handler function to extract string from fields
@ 2011-11-23 18:19 Julien Desfossez
  2011-11-28 14:26 ` [lttng-dev] " Mathieu Desnoyers
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Desfossez @ 2011-11-23 18:19 UTC (permalink / raw)


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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [lttng-dev] [BABELTRACE PATCH] Handler function to extract string from fields
  2011-11-23 18:19 [ltt-dev] [BABELTRACE PATCH] Handler function to extract string from fields Julien Desfossez
@ 2011-11-28 14:26 ` Mathieu Desnoyers
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Desnoyers @ 2011-11-28 14:26 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-28 14:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-23 18:19 [ltt-dev] [BABELTRACE PATCH] Handler function to extract string from fields Julien Desfossez
2011-11-28 14:26 ` [lttng-dev] " Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox