core: Port libotutil to local-alloc
This commit is contained in:
parent
ca08ad6c5e
commit
87f45052af
|
|
@ -54,8 +54,8 @@ ot_gfile_ensure_directory (GFile *dir,
|
||||||
gboolean with_parents,
|
gboolean with_parents,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GError *temp_error = NULL;
|
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
GError *temp_error = NULL;
|
||||||
|
|
||||||
if (with_parents)
|
if (with_parents)
|
||||||
ret = g_file_make_directory_with_parents (dir, NULL, &temp_error);
|
ret = g_file_make_directory_with_parents (dir, NULL, &temp_error);
|
||||||
|
|
@ -164,15 +164,15 @@ ot_gfile_rename (GFile *from,
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ot_gfile_load_contents_utf8 (GFile *file,
|
ot_gfile_load_contents_utf8 (GFile *file,
|
||||||
char **contents_out,
|
char **out_contents,
|
||||||
char **etag_out,
|
char **out_etag,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
char *ret_contents = NULL;
|
|
||||||
char *ret_etag = NULL;
|
|
||||||
gsize len;
|
|
||||||
gboolean ret = FALSE;
|
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))
|
if (!g_file_load_contents (file, cancellable, &ret_contents, &len, &ret_etag, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -185,20 +185,10 @@ ot_gfile_load_contents_utf8 (GFile *file,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contents_out)
|
|
||||||
{
|
|
||||||
*contents_out = ret_contents;
|
|
||||||
ret_contents = NULL;
|
|
||||||
}
|
|
||||||
if (etag_out)
|
|
||||||
{
|
|
||||||
*etag_out = ret_etag;
|
|
||||||
ret_etag = NULL;
|
|
||||||
}
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
ot_transfer_out_value (out_contents, &ret_contents);
|
||||||
|
ot_transfer_out_value (out_etag, &ret_etag);
|
||||||
out:
|
out:
|
||||||
g_free (ret_contents);
|
|
||||||
g_free (ret_etag);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -305,14 +295,14 @@ ot_gfile_merge_dirs (GFile *destination,
|
||||||
const char *dest_path = NULL;
|
const char *dest_path = NULL;
|
||||||
const char *src_path = NULL;
|
const char *src_path = NULL;
|
||||||
GError *temp_error = 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;
|
const char *name;
|
||||||
guint32 type;
|
guint32 type;
|
||||||
const int move_flags = G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS | G_FILE_COPY_ALL_METADATA;
|
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);
|
dest_path = ot_gfile_get_path_cached (destination);
|
||||||
src_path = ot_gfile_get_path_cached (src);
|
src_path = ot_gfile_get_path_cached (src);
|
||||||
|
|
@ -379,10 +369,5 @@ ot_gfile_merge_dirs (GFile *destination,
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,12 @@ gboolean
|
||||||
ot_util_spawn_pager (GOutputStream **out_stream,
|
ot_util_spawn_pager (GOutputStream **out_stream,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
gboolean ret = FALSE;
|
||||||
const char *pager;
|
const char *pager;
|
||||||
char *argv[2];
|
char *argv[2];
|
||||||
int stdin_fd;
|
int stdin_fd;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
gboolean ret = FALSE;
|
ot_lfree GOutputStream *ret_stream = NULL;
|
||||||
GOutputStream *ret_stream = NULL;
|
|
||||||
|
|
||||||
if (!isatty (1))
|
if (!isatty (1))
|
||||||
{
|
{
|
||||||
|
|
@ -70,7 +70,6 @@ ot_util_spawn_pager (GOutputStream **out_stream,
|
||||||
ot_transfer_out_value(out_stream, &ret_stream);
|
ot_transfer_out_value(out_stream, &ret_stream);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
g_clear_object (&ret_stream);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,8 +128,8 @@ ot_util_path_split_validate (const char *path,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GPtrArray *ret_components = NULL;
|
|
||||||
int i;
|
int i;
|
||||||
|
ot_lptrarray GPtrArray *ret_components = NULL;
|
||||||
|
|
||||||
if (strlen (path) > PATH_MAX)
|
if (strlen (path) > PATH_MAX)
|
||||||
{
|
{
|
||||||
|
|
@ -158,8 +157,6 @@ ot_util_path_split_validate (const char *path,
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
ot_transfer_out_value(out_components, &ret_components);
|
ot_transfer_out_value(out_components, &ret_components);
|
||||||
out:
|
out:
|
||||||
if (ret_components)
|
|
||||||
g_ptr_array_unref (ret_components);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,9 +113,9 @@ ot_util_variant_map (GFile *src,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GMappedFile *mfile = NULL;
|
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
ot_lvariant GVariant *ret_variant = NULL;
|
ot_lvariant GVariant *ret_variant = NULL;
|
||||||
|
GMappedFile *mfile = NULL;
|
||||||
|
|
||||||
path = ot_gfile_get_path_cached (src);
|
path = ot_gfile_get_path_cached (src);
|
||||||
mfile = g_mapped_file_new (path, FALSE, error);
|
mfile = g_mapped_file_new (path, FALSE, error);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue