4 * Strings read/write functions.
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/ctf/types.h>
20 #include <limits.h> /* C99 limits */
23 void ctf_string_copy(struct stream_pos
*dest
, struct stream_pos
*src
,
24 const struct type_class_string
*string_class
)
27 unsigned char *destaddr
, *srcaddr
;
29 align_pos(src
, string_class
->p
.alignment
);
30 srcaddr
= get_pos_addr(src
);
31 len
= strlen(srcaddr
) + 1;
34 align_pos(dest
, string_class
->p
.alignment
);
35 destaddr
= get_pos_addr(dest
);
36 strcpy(destaddr
, srcaddr
);
42 void ctf_string_read(unsigned char **dest
, struct stream_pos
*src
,
43 const struct type_class_string
*string_class
)
46 unsigned char *srcaddr
;
48 align_pos(src
, string_class
->p
.alignment
);
49 srcaddr
= get_pos_addr(src
);
50 len
= strlen(srcaddr
) + 1;
53 *dest
= g_realloc(*dest
, len
);
54 strcpy(dest
, srcaddr
);
59 void ctf_string_write(struct stream_pos
*dest
, const unsigned char *src
,
60 const struct type_class_string
*string_class
)
63 unsigned char *destaddr
;
65 align_pos(dest
, string_class
->p
.alignment
);
66 len
= strlen(src
) + 1;
69 destaddr
= get_pos_addr(dest
);
70 strcpy(destaddr
, src
);
75 void ctf_string_free_temp(unsigned char *string
)
This page took 0.054618 seconds and 5 git commands to generate.