4 * BabelTrace - String Type Converter
6 * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
19 #include <babeltrace/compiler.h>
20 #include <babeltrace/align.h>
21 #include <babeltrace/format.h>
24 struct definition
*_string_definition_new(struct declaration
*declaration
,
25 struct definition_scope
*parent_scope
);
27 void _string_definition_free(struct definition
*definition
);
29 void string_copy(struct stream_pos
*dest
, const struct format
*fdest
,
30 struct stream_pos
*src
, const struct format
*fsrc
,
31 struct definition
*definition
)
33 struct definition_string
*string
=
34 container_of(definition
, struct definition_string
, p
);
35 struct declaration_string
*string_declaration
= string
->declaration
;
37 if (fsrc
->string_copy
== fdest
->string_copy
) {
38 fsrc
->string_copy(dest
, src
, string_declaration
);
42 fsrc
->string_read(&tmp
, src
, string_declaration
);
43 fdest
->string_write(dest
, tmp
, string_declaration
);
44 fsrc
->string_free_temp(tmp
);
49 void _string_declaration_free(struct declaration
*declaration
)
51 struct declaration_string
*string_declaration
=
52 container_of(declaration
, struct declaration_string
, p
);
53 g_free(string_declaration
);
56 struct declaration_string
*string_declaration_new(const char *name
)
58 struct declaration_string
*string_declaration
;
60 string_declaration
= g_new(struct declaration_string
, 1);
61 string_declaration
->p
.id
= CTF_TYPE_STRING
;
62 string_declaration
->p
.name
= g_quark_from_string(name
);
63 string_declaration
->p
.alignment
= CHAR_BIT
;
64 string_declaration
->p
.copy
= string_copy
;
65 string_declaration
->p
.declaration_free
= _string_declaration_free
;
66 string_declaration
->p
.definition_new
= _string_definition_new
;
67 string_declaration
->p
.definition_free
= _string_definition_free
;
68 string_declaration
->p
.ref
= 1;
69 return string_declaration
;
74 _string_definition_new(struct declaration
*declaration
,
75 struct definition_scope
*parent_scope
)
77 struct declaration_string
*string_declaration
=
78 container_of(declaration
, struct declaration_string
, p
);
79 struct definition_string
*string
;
81 string
= g_new(struct definition_string
, 1);
82 declaration_ref(&string_declaration
->p
);
83 string
->p
.declaration
= declaration
;
84 string
->declaration
= string_declaration
;
91 void _string_definition_free(struct definition
*definition
)
93 struct definition_string
*string
=
94 container_of(definition
, struct definition_string
, p
);
96 declaration_unref(string
->p
.declaration
);
97 g_free(string
->value
);
This page took 0.033827 seconds and 4 git commands to generate.