mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-capture: free deduplicated array entries
This commit is contained in:
@ -1343,7 +1343,7 @@ array_append (const char ***files,
|
||||
*files = new_files;
|
||||
}
|
||||
|
||||
(*files)[*n_files] = new_element ? strdup (new_element) : NULL;
|
||||
(*files)[*n_files] = new_element ? sysprof_strdup (new_element) : NULL;
|
||||
*n_files = *n_files + 1;
|
||||
assert (*n_files <= *n_files_allocated);
|
||||
|
||||
@ -1362,7 +1362,10 @@ array_deduplicate (const char **files,
|
||||
for (last_written = 0, next_to_read = 1; last_written <= next_to_read && next_to_read < *n_files;)
|
||||
{
|
||||
if (strcmp (files[next_to_read], files[last_written]) == 0)
|
||||
next_to_read++;
|
||||
{
|
||||
free ((char *)files[next_to_read]);
|
||||
next_to_read++;
|
||||
}
|
||||
else
|
||||
files[++last_written] = files[next_to_read++];
|
||||
}
|
||||
|
||||
@ -732,7 +732,7 @@ test_reader_writer_file (void)
|
||||
g_autofree gchar *data = NULL;
|
||||
g_autofree gchar *testfile = NULL;
|
||||
GByteArray *buf = g_byte_array_new ();
|
||||
g_autofree const gchar **files = NULL;
|
||||
const char **files;
|
||||
SysprofCaptureWriter *writer;
|
||||
SysprofCaptureReader *reader;
|
||||
SysprofCaptureFrameType type;
|
||||
@ -799,6 +799,7 @@ test_reader_writer_file (void)
|
||||
g_assert_nonnull (files);
|
||||
g_assert_cmpstr (files[0], ==, testfile);
|
||||
g_assert_null (files[1]);
|
||||
free (files);
|
||||
|
||||
sysprof_capture_reader_reset (reader);
|
||||
new_fd = sysprof_memfd_create ("[sysprof-capture-file]");
|
||||
|
||||
Reference in New Issue
Block a user