4d57914112fe3a7aceeed0abda1621168e8d22f5
4 * BabelTrace - String Type Converter
6 * Copyright 2010 - 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/types.h>
23 void string_copy(struct stream_pos
*dest
, const struct format
*fdest
,
24 struct stream_pos
*src
, const struct format
*fsrc
,
25 const struct type_class
*type_class
)
27 struct type_class_string
*string_class
=
28 container_of(type_class
, struct type_class_string
, p
);
30 if (fsrc
->string_copy
== fdest
->string_copy
) {
31 fsrc
->string_copy(dest
, src
, string_class
);
33 unsigned char *tmp
= NULL
;
35 fsrc
->string_read(&tmp
, src
, string_class
);
36 fdest
->string_write(dest
, tmp
, string_class
);
37 fsrc
->string_free_temp(tmp
);
41 void string_type_free(struct type_class_string
*string_class
)
46 static void _string_type_free(struct type_class
*type_class
)
48 struct type_class_string
*string_class
=
49 container_of(type_class
, struct type_class_string
, p
);
50 string_type_free(string_class
);
53 struct type_class_string
*string_type_new(const char *name
)
55 struct type_class_string
*string_class
;
58 string_class
= g_new(struct type_class_string
, 1);
59 string_class
->p
.name
= g_quark_from_string(name
);
60 string_class
->p
.alignment
= CHAR_BIT
;
61 string_class
->p
.copy
= string_copy
;
62 string_class
->p
.free
= _string_type_free
;
63 if (string_class
->p
.name
) {
64 ret
= ctf_register_type(&string_class
->p
);
This page took 0.034626 seconds and 5 git commands to generate.