core: Port libotutil to local-alloc

This commit is contained in:
Colin Walters 2012-04-09 15:48:20 -04:00
parent ca08ad6c5e
commit 87f45052af
3 changed files with 17 additions and 35 deletions

View File

@ -54,8 +54,8 @@ ot_gfile_ensure_directory (GFile *dir,
gboolean with_parents,
GError **error)
{
GError *temp_error = NULL;
gboolean ret = FALSE;
GError *temp_error = NULL;
if (with_parents)
ret = g_file_make_directory_with_parents (dir, NULL, &temp_error);
@ -164,15 +164,15 @@ ot_gfile_rename (GFile *from,
gboolean
ot_gfile_load_contents_utf8 (GFile *file,
char **contents_out,
char **etag_out,
char **out_contents,
char **out_etag,
GCancellable *cancellable,
GError **error)
{
char *ret_contents = NULL;
char *ret_etag = NULL;
gsize len;
gboolean ret = FALSE;
gsize len;
ot_lfree char *ret_contents = NULL;
ot_lfree char *ret_etag = NULL;
if (!g_file_load_contents (file, cancellable, &ret_contents, &len, &ret_etag, error))
goto out;
@ -185,20 +185,10 @@ ot_gfile_load_contents_utf8 (GFile *file,
goto out;
}
if (contents_out)
{
*contents_out = ret_contents;
ret_contents = NULL;
}
if (etag_out)
{
*etag_out = ret_etag;
ret_etag = NULL;
}
ret = TRUE;
ot_transfer_out_value (out_contents, &ret_contents);
ot_transfer_out_value (out_etag, &ret_etag);
out:
g_free (ret_contents);
g_free (ret_etag);
return ret;
}
@ -305,14 +295,14 @@ ot_gfile_merge_dirs (GFile *destination,
const char *dest_path = NULL;
const char *src_path = NULL;
GError *temp_error = NULL;
GFileInfo *src_fileinfo = NULL;
GFileInfo *dest_fileinfo = NULL;
GFileEnumerator *src_enum = NULL;
GFile *dest_subfile = NULL;
GFile *src_subfile = NULL;
const char *name;
guint32 type;
const int move_flags = G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS | G_FILE_COPY_ALL_METADATA;
ot_lobj GFileInfo *src_fileinfo = NULL;
ot_lobj GFileInfo *dest_fileinfo = NULL;
ot_lobj GFileEnumerator *src_enum = NULL;
ot_lobj GFile *dest_subfile = NULL;
ot_lobj GFile *src_subfile = NULL;
dest_path = ot_gfile_get_path_cached (destination);
src_path = ot_gfile_get_path_cached (src);
@ -379,10 +369,5 @@ ot_gfile_merge_dirs (GFile *destination,
ret = TRUE;
out:
g_clear_object (&src_fileinfo);
g_clear_object (&dest_fileinfo);
g_clear_object (&src_enum);
g_clear_object (&dest_subfile);
g_clear_object (&src_subfile);
return ret;
}

View File

@ -37,12 +37,12 @@ gboolean
ot_util_spawn_pager (GOutputStream **out_stream,
GError **error)
{
gboolean ret = FALSE;
const char *pager;
char *argv[2];
int stdin_fd;
pid_t pid;
gboolean ret = FALSE;
GOutputStream *ret_stream = NULL;
ot_lfree GOutputStream *ret_stream = NULL;
if (!isatty (1))
{
@ -70,7 +70,6 @@ ot_util_spawn_pager (GOutputStream **out_stream,
ot_transfer_out_value(out_stream, &ret_stream);
ret = TRUE;
out:
g_clear_object (&ret_stream);
return ret;
}
@ -129,8 +128,8 @@ ot_util_path_split_validate (const char *path,
GError **error)
{
gboolean ret = FALSE;
GPtrArray *ret_components = NULL;
int i;
ot_lptrarray GPtrArray *ret_components = NULL;
if (strlen (path) > PATH_MAX)
{
@ -158,8 +157,6 @@ ot_util_path_split_validate (const char *path,
ret = TRUE;
ot_transfer_out_value(out_components, &ret_components);
out:
if (ret_components)
g_ptr_array_unref (ret_components);
return ret;
}

View File

@ -113,9 +113,9 @@ ot_util_variant_map (GFile *src,
GError **error)
{
gboolean ret = FALSE;
GMappedFile *mfile = NULL;
const char *path = NULL;
ot_lvariant GVariant *ret_variant = NULL;
GMappedFile *mfile = NULL;
path = ot_gfile_get_path_cached (src);
mfile = g_mapped_file_new (path, FALSE, error);