2 * BabelTrace - Array Type Converter
4 * Copyright (c) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <babeltrace/compiler.h>
22 #include <babeltrace/types.h>
24 void array_copy(struct stream_pos
*dest
, const struct format
*fdest
,
25 struct stream_pos
*src
, const struct format
*fsrc
,
26 const struct type_class
*type_class
)
28 struct type_class_array
*array_class
=
29 container_of(type_class
, struct type_class_array
, p
);
32 fsrc
->array_begin(src
, array_class
);
33 fdest
->array_begin(dest
, array_class
);
35 for (i
= 0; i
< array_class
->len
; i
++) {
36 struct type_class
*elem_class
= array_class
->elem
;
37 elem_class
->copy(dest
, fdest
, src
, fsrc
, &elem_class
->p
);
39 fsrc
->array_end(src
, array_class
);
40 fdest
->array_end(dest
, array_class
);
43 void array_type_free(struct type_class_array
*array_class
)
45 array_class
->elem
->free(&array_class
->elem
->p
);
49 static void _array_type_free(struct type_class
*type_class
)
51 struct type_class_struct
*array_class
=
52 container_of(type_class
, struct type_class_array
, p
);
53 array_type_free(array_class
);
56 struct type_class_array
*array_type_new(const char *name
, size_t len
,
57 struct type_class
*elem
)
59 struct type_class_array
*array_class
;
62 array_class
= g_new(struct type_class_array
, 1);
63 type_class
= &float_class
->p
;
65 array_class
->len
= len
;
66 type_class
->name
= g_quark_from_string(name
);
67 /* No need to align the array, the first element will align itself */
68 type_class
->alignment
= 1;
69 type_class
->copy
= array_copy
;
70 type_class
->free
= _array_type_free
;
72 if (type_class
->name
) {
73 ret
= ctf_register_type(type_class
);
80 array_class
->elem
->free(&array_class
->elem
->p
);
This page took 0.030689 seconds and 4 git commands to generate.