* all copies or substantial portions of the Software.
*/
+#include <babeltrace/babeltrace.h>
#include <babeltrace/ctf/types.h>
#include <limits.h> /* C99 limits */
#include <string.h>
-void ctf_string_copy(struct stream_pos *pdest, struct stream_pos *psrc,
- const struct declaration_string *string_declaration)
-{
- struct ctf_stream_pos *dest = ctf_pos(pdest);
- struct ctf_stream_pos *src = ctf_pos(psrc);
- size_t len;
- char *destaddr, *srcaddr;
-
- ctf_align_pos(src, string_declaration->p.alignment);
- srcaddr = ctf_get_pos_addr(src);
- len = strlen(srcaddr) + 1;
- if (dest->dummy)
- goto end;
- ctf_align_pos(dest, string_declaration->p.alignment);
- destaddr = ctf_get_pos_addr(dest);
- strcpy(destaddr, srcaddr);
-end:
- ctf_move_pos(dest, len);
- ctf_move_pos(src, len);
-}
-
void ctf_string_read(struct stream_pos *ppos, struct definition *definition)
{
struct definition_string *string_definition =
g_realloc(string_definition->value, len);
string_definition->alloc_len = len;
}
+ printf_debug("CTF string read %s\n", srcaddr);
memcpy(string_definition->value, srcaddr, len);
string_definition->len = len;
- ctf_move_pos(pos, len);
+ ctf_move_pos(pos, len * CHAR_BIT);
}
void ctf_string_write(struct stream_pos *ppos,
if (pos->dummy)
goto end;
destaddr = ctf_get_pos_addr(pos);
- strcpy(destaddr, string_definition->value);
+ memcpy(destaddr, string_definition->value, len);
end:
- ctf_move_pos(pos, len);
+ ctf_move_pos(pos, len * CHAR_BIT);
}