[sysprof] libsysprof-capture: add writer buffer size helper



commit 19f4a6ae7048339afecffad168e5df060d1db112
Author: Christian Hergert <chergert redhat com>
Date:   Fri May 24 18:19:57 2019 -0700

    libsysprof-capture: add writer buffer size helper
    
    This could be useful to know what you can actually shove into the capture
    file based on size.

 src/libsysprof-capture/sysprof-capture-writer.c | 8 ++++++++
 src/libsysprof-capture/sysprof-capture-writer.h | 2 ++
 src/tests/test-capture.c                        | 1 +
 3 files changed, 11 insertions(+)
---
diff --git a/src/libsysprof-capture/sysprof-capture-writer.c b/src/libsysprof-capture/sysprof-capture-writer.c
index 1d416c0..8eefda2 100644
--- a/src/libsysprof-capture/sysprof-capture-writer.c
+++ b/src/libsysprof-capture/sysprof-capture-writer.c
@@ -1296,3 +1296,11 @@ sysprof_capture_writer_new_from_env (gsize buffer_size)
 
   return sysprof_capture_writer_new_from_fd (dup (fd), buffer_size);
 }
+
+gsize
+sysprof_capture_writer_get_buffer_size (SysprofCaptureWriter *self)
+{
+  g_return_val_if_fail (self != NULL, 0);
+
+  return self->len;
+}
diff --git a/src/libsysprof-capture/sysprof-capture-writer.h b/src/libsysprof-capture/sysprof-capture-writer.h
index 2074261..9e4f025 100644
--- a/src/libsysprof-capture/sysprof-capture-writer.h
+++ b/src/libsysprof-capture/sysprof-capture-writer.h
@@ -36,6 +36,8 @@ SYSPROF_AVAILABLE_IN_ALL
 SysprofCaptureWriter *sysprof_capture_writer_new_from_fd     (int                                fd,
                                                               gsize                              
buffer_size);
 SYSPROF_AVAILABLE_IN_ALL
+gsize                 sysprof_capture_writer_get_buffer_size (SysprofCaptureWriter              *self);
+SYSPROF_AVAILABLE_IN_ALL
 SysprofCaptureWriter *sysprof_capture_writer_ref             (SysprofCaptureWriter              *self);
 SYSPROF_AVAILABLE_IN_ALL
 void                  sysprof_capture_writer_unref           (SysprofCaptureWriter              *self);
diff --git a/src/tests/test-capture.c b/src/tests/test-capture.c
index 0094ab6..5242179 100644
--- a/src/tests/test-capture.c
+++ b/src/tests/test-capture.c
@@ -36,6 +36,7 @@ test_reader_basic (void)
 
   writer = sysprof_capture_writer_new ("capture-file", 0);
   g_assert (writer != NULL);
+  g_assert_cmpint (sysprof_capture_writer_get_buffer_size (writer), ==, 4096*64);
 
   sysprof_capture_writer_flush (writer);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]