Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers)
Subject: [lttng-dev] [BABELTRACE PATCH] Handler function to extract string from	fields
Date: Mon, 28 Nov 2011 09:26:28 -0500	[thread overview]
Message-ID: <20111128142627.GA18852@Krystal> (raw)
In-Reply-To: <1322072343-18749-1-git-send-email-julien.desfossez@polymtl.ca>

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



      reply	other threads:[~2011-11-28 14:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-23 18:19 [ltt-dev] " Julien Desfossez
2011-11-28 14:26 ` Mathieu Desnoyers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111128142627.GA18852@Krystal \
    --to=mathieu.desnoyers@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox