mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-capture: add raw frame helper
This helps when shuffling data between sources so that you can simply memcpy() into the destination buffer.
This commit is contained in:
@ -1609,3 +1609,30 @@ sysprof_capture_writer_add_allocation_copy (SysprofCaptureWriter *self,
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_sysprof_capture_writer_add_raw (SysprofCaptureWriter *self,
|
||||
const SysprofCaptureFrame *fr)
|
||||
{
|
||||
gpointer begin;
|
||||
gsize len;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((fr->len & 0x7) == 0);
|
||||
g_assert (fr->type < SYSPROF_CAPTURE_FRAME_LAST);
|
||||
|
||||
len = fr->len;
|
||||
|
||||
if (!(begin = sysprof_capture_writer_allocate (self, &len)))
|
||||
return FALSE;
|
||||
|
||||
g_assert (fr->len == len);
|
||||
g_assert (fr->type < 16);
|
||||
|
||||
memcpy (begin, fr, fr->len);
|
||||
|
||||
if (fr->type < G_N_ELEMENTS (self->stat.frame_count))
|
||||
self->stat.frame_count[fr->type]++;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -237,6 +237,9 @@ gboolean sysprof_capture_writer_cat (Sy
|
||||
SysprofCaptureReader *reader,
|
||||
GError **error);
|
||||
G_GNUC_INTERNAL
|
||||
gboolean _sysprof_capture_writer_add_raw (SysprofCaptureWriter *self,
|
||||
const SysprofCaptureFrame *frame);
|
||||
G_GNUC_INTERNAL
|
||||
gboolean _sysprof_capture_writer_splice_from_fd (SysprofCaptureWriter *self,
|
||||
int fd,
|
||||
GError **error) G_GNUC_INTERNAL;
|
||||
|
||||
Reference in New Issue
Block a user