tree-wide: Convert to using autoptr(GString) vs g_string_free(...,TRUE)
If we're freeing the segment, it's basically always better to use `autoptr()`. Fewer lines, more reliable, etc. Noticed an instance of this in the pull code while reviewing a different PR, decided to do a grep for it and fix it tree wide. Closes: #836 Approved by: pwithnall
This commit is contained in:
1 parent
bf9772f231
commit
712bf21914
13 files changed
+21
-63
No files matched your search
@@ -148,7 +148,7 @@ _ostree_bootloader_grub2_generate_config (OstreeSysroot *sysroot
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GString *output = g_string_new ("");
|
||||
g_autoptr(GString) output = g_string_new ("");
|
||||
g_autoptr(GOutputStream) out_stream = NULL;
|
||||
g_autoptr(GPtrArray) loader_configs = NULL;
|
||||
guint i;
|
||||
@@ -260,8 +260,6 @@ _ostree_bootloader_grub2_generate_config (OstreeSysroot *sysroot
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (output)
|
||||
g_string_free (output, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -433,7 +433,7 @@ add_size_index_to_metadata (OstreeRepo *self,
|
||||
{
|
||||
guint8 csum[OSTREE_SHA256_DIGEST_LEN];
|
||||
const char *e_checksum = sorted_keys->pdata[i];
|
||||
GString *buffer = g_string_new (NULL);
|
||||
g_autoptr(GString) buffer = g_string_new (NULL);
|
||||
|
||||
ostree_checksum_inplace_to_bytes (e_checksum, csum);
|
||||
g_string_append_len (buffer, (char*)csum, sizeof (csum));
|
||||
@@ -444,7 +444,6 @@ add_size_index_to_metadata (OstreeRepo *self,
|
||||
|
||||
g_variant_builder_add (&index_builder, "@ay",
|
||||
ot_gvariant_new_bytearray ((guint8*)buffer->str, buffer->len));
|
||||
g_string_free (buffer, TRUE);
|
||||
}
|
||||
|
||||
g_variant_builder_add (builder, "{sv}", "ostree.sizes",
|
||||
|
||||
@@ -3474,8 +3474,8 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
bytes_transferred = _ostree_fetcher_bytes_transferred (pull_data->fetcher);
|
||||
if (bytes_transferred > 0 && pull_data->progress)
|
||||
{
|
||||
guint shift;
|
||||
GString *buf = g_string_new ("");
|
||||
guint shift;
|
||||
g_autoptr(GString) buf = g_string_new ("");
|
||||
|
||||
/* Ensure the rest of the progress keys are set appropriately. */
|
||||
update_progress (pull_data);
|
||||
@@ -3499,7 +3499,6 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
(guint) ((end_time - pull_data->start_time) / G_USEC_PER_SEC));
|
||||
|
||||
ostree_async_progress_set_status (pull_data->progress, buf->str);
|
||||
g_string_free (buf, TRUE);
|
||||
}
|
||||
|
||||
/* iterate over commits fetched and delete any commitpartial files */
|
||||
|
||||
@@ -3717,7 +3717,6 @@ void
|
||||
ostree_repo_pull_default_console_progress_changed (OstreeAsyncProgress *progress,
|
||||
gpointer user_data)
|
||||
{
|
||||
GString *buf;
|
||||
g_autofree char *status = NULL;
|
||||
gboolean scanning;
|
||||
guint outstanding_fetches;
|
||||
@@ -3729,7 +3728,7 @@ ostree_repo_pull_default_console_progress_changed (OstreeAsyncProgress *progress
|
||||
guint fetched_delta_part_fallbacks;
|
||||
guint total_delta_part_fallbacks;
|
||||
|
||||
buf = g_string_new ("");
|
||||
g_autoptr(GString) buf = g_string_new ("");
|
||||
|
||||
ostree_async_progress_get (progress,
|
||||
"outstanding-fetches", "u", &outstanding_fetches,
|
||||
@@ -3838,8 +3837,6 @@ ostree_repo_pull_default_console_progress_changed (OstreeAsyncProgress *progress
|
||||
}
|
||||
|
||||
glnx_console_text (buf->str);
|
||||
|
||||
g_string_free (buf, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user