Use g_autoptr() for GIO object types
GLib 2.44 supplies all the necessary autocleanup macros for GIO types, and libglnx backports the relevant macros for ostree.
This commit is contained in:
1 parent
7a62d64968
commit
4ee1acd981
51 files changed
+320
-320
No files matched your search
@@ -147,7 +147,7 @@ ot_checksum_file (GFile *file,
|
||||
{
|
||||
GChecksum *checksum = NULL;
|
||||
char *ret = NULL;
|
||||
gs_unref_object GInputStream *in = NULL;
|
||||
g_autoptr(GInputStream) in = NULL;
|
||||
|
||||
in = (GInputStream*)g_file_read (file, cancellable, error);
|
||||
if (!in)
|
||||
|
||||
@@ -161,8 +161,8 @@ ot_gfile_get_symlink_target_from_info (GFile *path,
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
const char *target;
|
||||
gs_unref_object GFile *path_parent = NULL;
|
||||
gs_unref_object GFile *ret_target = NULL;
|
||||
g_autoptr(GFile) path_parent = NULL;
|
||||
g_autoptr(GFile) ret_target = NULL;
|
||||
|
||||
if (g_file_info_get_file_type (file_info) != G_FILE_TYPE_SYMBOLIC_LINK)
|
||||
{
|
||||
@@ -191,7 +191,7 @@ ot_gfile_query_info_allow_noent (GFile *path,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object GFileInfo *ret_file_info = NULL;
|
||||
g_autoptr(GFileInfo) ret_file_info = NULL;
|
||||
GError *temp_error = NULL;
|
||||
|
||||
ret_file_info = g_file_query_info (path, queryopts, flags,
|
||||
@@ -222,8 +222,8 @@ ot_gfile_query_symlink_target_allow_noent (GFile *path,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object GFileInfo *file_info = NULL;
|
||||
gs_unref_object GFile *ret_target = NULL;
|
||||
g_autoptr(GFileInfo) file_info = NULL;
|
||||
g_autoptr(GFile) ret_target = NULL;
|
||||
|
||||
if (!ot_gfile_query_info_allow_noent (path, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
@@ -291,8 +291,8 @@ ot_file_replace_contents_at (int dfd,
|
||||
gboolean ret = FALSE;
|
||||
int fd;
|
||||
g_autofree char *tmpname = NULL;
|
||||
gs_unref_object GOutputStream *stream = NULL;
|
||||
gs_unref_object GInputStream *instream = NULL;
|
||||
g_autoptr(GOutputStream) stream = NULL;
|
||||
g_autoptr(GInputStream) instream = NULL;
|
||||
|
||||
if (!gs_file_open_in_tmpdir_at (dfd, 0644,
|
||||
&tmpname, &stream,
|
||||
@@ -356,7 +356,7 @@ ot_gfile_replace_contents_fsync (GFile *path,
|
||||
gboolean ret = FALSE;
|
||||
int parent_dfd;
|
||||
const char *target_basename = gs_file_get_basename_cached (path);
|
||||
gs_unref_object GFile *parent = NULL;
|
||||
g_autoptr(GFile) parent = NULL;
|
||||
|
||||
parent = g_file_get_parent (path);
|
||||
|
||||
@@ -457,7 +457,7 @@ ot_util_ensure_directory_and_fsync (GFile *dir,
|
||||
gboolean ret = FALSE;
|
||||
int parentfd = -1;
|
||||
const char *basename = gs_file_get_basename_cached (dir);
|
||||
gs_unref_object GFile *parent = g_file_get_parent (dir);
|
||||
g_autoptr(GFile) parent = g_file_get_parent (dir);
|
||||
|
||||
again:
|
||||
parentfd = open (gs_file_get_path_cached (parent),
|
||||
@@ -528,9 +528,9 @@ ot_gfile_atomic_symlink_swap (GFile *path,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object GFile *parent = g_file_get_parent (path);
|
||||
g_autoptr(GFile) parent = g_file_get_parent (path);
|
||||
g_autofree char *tmpname = g_strconcat (gs_file_get_basename_cached (path), ".tmp", NULL);
|
||||
gs_unref_object GFile *tmppath = g_file_get_child (parent, tmpname);
|
||||
g_autoptr(GFile) tmppath = g_file_get_child (parent, tmpname);
|
||||
int parent_dfd = -1;
|
||||
|
||||
if (!ot_gfile_ensure_unlinked (tmppath, cancellable, error))
|
||||
|
||||
@@ -108,7 +108,7 @@ ot_gpgme_ctx_tmp_home_dir (gpgme_ctx_t gpgme_ctx,
|
||||
if (out_pubring_stream != NULL)
|
||||
{
|
||||
GFileOutputStream *pubring_stream;
|
||||
glnx_unref_object GFile *pubring_file = NULL;
|
||||
g_autoptr(GFile) pubring_file = NULL;
|
||||
g_autofree char *pubring_path = NULL;
|
||||
|
||||
pubring_path = g_build_filename (tmp_home_dir, "pubring.gpg", NULL);
|
||||
|
||||
@@ -85,7 +85,7 @@ ot_util_variant_save (GFile *dest,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object GOutputStream *out = NULL;
|
||||
g_autoptr(GOutputStream) out = NULL;
|
||||
gsize bytes_written;
|
||||
|
||||
out = (GOutputStream*)g_file_replace (dest, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION,
|
||||
@@ -220,7 +220,7 @@ ot_util_variant_from_stream (GInputStream *src,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object GMemoryOutputStream *data_stream = NULL;
|
||||
g_autoptr(GMemoryOutputStream) data_stream = NULL;
|
||||
gs_unref_variant GVariant *ret_variant = NULL;
|
||||
|
||||
data_stream = (GMemoryOutputStream*)g_memory_output_stream_new (NULL, 0, g_realloc, g_free);
|
||||
|
||||
Reference in new issue
Block a user