aboutsummaryrefslogtreecommitdiff
path: root/display_args.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-01-07 01:04:40 +0100
committerPetr Machata <pmachata@redhat.com>2012-08-29 19:02:07 +0200
commit4767187d0d7924bfe5028fe3e29e3b018bc9c99b (patch)
treef4aad6f467d1979528a5070181358b60bb480c4f /display_args.c
parent940ec0650bfe0f1deda96d3561be3d0006df92fc (diff)
downloadltrace-4767187d0d7924bfe5028fe3e29e3b018bc9c99b.tar.gz
Add value_string_to_charp
- I consider this a temporary solution before ARGTYPE_STRING is removed. Since we need to handle strings as array(char, zero)*, it's necessary to do this conversion by hand every once in a while. This code implements such transformation.
Diffstat (limited to 'display_args.c')
-rw-r--r--display_args.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/display_args.c b/display_args.c
index 270381d..1cfbe6d 100644
--- a/display_args.c
+++ b/display_args.c
@@ -311,8 +311,7 @@ int
format_argument(FILE *stream, struct value *value, struct value_dict *arguments)
{
switch (value->type->type) {
- struct value tmp;
- struct arg_type_info info[2];
+ struct value *tmp;
int ret;
case ARGTYPE_VOID:
@@ -362,21 +361,11 @@ format_argument(FILE *stream, struct value *value, struct value_dict *arguments)
options.strlen, 0, "\"", "\"", "");
case ARGTYPE_STRING_N:
- /* Strings are in fact char pointers. Smuggle in the
- * pointer here. */
-
- type_init_array(&info[1], type_get_simple(ARGTYPE_CHAR), 0,
- value->type->u.string_n_info.length, 0);
- type_init_pointer(&info[0], &info[1], 0);
-
- value_clone(&tmp, value);
- value_set_type(&tmp, info, 0);
-
- ret = format_argument(stream, &tmp, arguments);
-
- value_destroy(&tmp);
- type_destroy(&info[0]);
- type_destroy(&info[1]);
+ tmp = value_string_to_charp(value);
+ if (tmp == NULL)
+ return -1;
+ ret = format_argument(stream, tmp, arguments);
+ value_destroy(tmp);
return ret;
case ARGTYPE_ENUM: