mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 08:00:53 +00:00
@ -151,9 +151,11 @@ sysprof_capture_cursor_foreach (SysprofCaptureCursor *self,
|
|||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
assert (self != NULL);
|
assert (self != NULL);
|
||||||
assert (self->reader != NULL);
|
|
||||||
assert (callback != NULL);
|
assert (callback != NULL);
|
||||||
|
|
||||||
|
if (self->reader == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
const SysprofCaptureFrame *frame;
|
const SysprofCaptureFrame *frame;
|
||||||
@ -260,9 +262,9 @@ void
|
|||||||
sysprof_capture_cursor_reset (SysprofCaptureCursor *self)
|
sysprof_capture_cursor_reset (SysprofCaptureCursor *self)
|
||||||
{
|
{
|
||||||
assert (self != NULL);
|
assert (self != NULL);
|
||||||
assert (self->reader != NULL);
|
|
||||||
|
|
||||||
sysprof_capture_reader_reset (self->reader);
|
if (self->reader != NULL)
|
||||||
|
sysprof_capture_reader_reset (self->reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -305,18 +307,20 @@ sysprof_capture_cursor_add_condition (SysprofCaptureCursor *self,
|
|||||||
* sysprof_capture_cursor_new:
|
* sysprof_capture_cursor_new:
|
||||||
* @self: a #SysprofCaptureCursor
|
* @self: a #SysprofCaptureCursor
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): a new cursor for @reader
|
* Returns: (transfer full) (nullable): a new cursor for @reader
|
||||||
*/
|
*/
|
||||||
SysprofCaptureCursor *
|
SysprofCaptureCursor *
|
||||||
sysprof_capture_cursor_new (SysprofCaptureReader *reader)
|
sysprof_capture_cursor_new (SysprofCaptureReader *reader)
|
||||||
{
|
{
|
||||||
SysprofCaptureCursor *self;
|
SysprofCaptureCursor *self;
|
||||||
|
|
||||||
assert (reader != NULL);
|
|
||||||
|
|
||||||
self = sysprof_capture_cursor_init ();
|
self = sysprof_capture_cursor_init ();
|
||||||
self->reader = sysprof_capture_reader_copy (reader);
|
|
||||||
sysprof_capture_reader_reset (self->reader);
|
if (reader != NULL)
|
||||||
|
{
|
||||||
|
self->reader = sysprof_capture_reader_copy (reader);
|
||||||
|
sysprof_capture_reader_reset (self->reader);
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -326,7 +330,7 @@ sysprof_capture_cursor_new (SysprofCaptureReader *reader)
|
|||||||
*
|
*
|
||||||
* Gets the underlying reader that is used by the cursor.
|
* Gets the underlying reader that is used by the cursor.
|
||||||
*
|
*
|
||||||
* Returns: (transfer none): An #SysprofCaptureReader
|
* Returns: (transfer none) (nullable): An #SysprofCaptureReader
|
||||||
*/
|
*/
|
||||||
SysprofCaptureReader *
|
SysprofCaptureReader *
|
||||||
sysprof_capture_cursor_get_reader (SysprofCaptureCursor *self)
|
sysprof_capture_cursor_get_reader (SysprofCaptureCursor *self)
|
||||||
|
|||||||
@ -69,6 +69,16 @@ test_cursor_basic (void)
|
|||||||
g_unlink ("capture-cursor-file");
|
g_unlink ("capture-cursor-file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_cursor_null (void)
|
||||||
|
{
|
||||||
|
SysprofCaptureCursor *cursor = sysprof_capture_cursor_new (NULL);
|
||||||
|
gint count = 0;
|
||||||
|
sysprof_capture_cursor_foreach (cursor, increment, &count);
|
||||||
|
g_assert_cmpint (count, ==, 0);
|
||||||
|
g_clear_pointer (&cursor, sysprof_capture_cursor_unref);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
@ -76,5 +86,6 @@ main (int argc,
|
|||||||
sysprof_clock_init ();
|
sysprof_clock_init ();
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
g_test_add_func ("/SysprofCaptureCursor/basic", test_cursor_basic);
|
g_test_add_func ("/SysprofCaptureCursor/basic", test_cursor_basic);
|
||||||
|
g_test_add_func ("/SysprofCaptureCursor/null", test_cursor_null);
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user