mirror of https://github.com/MidnightCommander/mc
Use g_string_new_take().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
2019737846
commit
2d86b8889f
|
@ -140,6 +140,41 @@ g_queue_clear_full (GQueue * queue, GDestroyNotify free_func)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#if ! GLIB_CHECK_VERSION (2, 77, 0)
|
||||
/**
|
||||
* g_string_new_take:
|
||||
* @init: (nullable): initial text used as the string.
|
||||
* Ownership of the string is transferred to the #GString.
|
||||
* Passing NULL creates an empty string.
|
||||
*
|
||||
* Creates a new #GString, initialized with the given string.
|
||||
*
|
||||
* After this call, @init belongs to the #GString and may no longer be
|
||||
* modified by the caller. The memory of @data has to be dynamically
|
||||
* allocated and will eventually be freed with g_free().
|
||||
*
|
||||
* Returns: the new #GString
|
||||
*/
|
||||
GString *
|
||||
g_string_new_take (char *init)
|
||||
{
|
||||
GString *string;
|
||||
|
||||
if (init == NULL)
|
||||
return g_string_new (NULL);
|
||||
|
||||
string = g_slice_new (GString);
|
||||
|
||||
string->str = init;
|
||||
string->len = strlen (string->str);
|
||||
string->allocated_len = string->len + 1;
|
||||
|
||||
return string;
|
||||
}
|
||||
#endif /* ! GLIB_CHECK_VERSION (2, 77, 0) */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* mc_g_string_copy:
|
||||
* @dest: (not nullable): the destination #GString. Its current contents are destroyed
|
||||
|
|
|
@ -25,6 +25,10 @@ void g_clear_list (GList ** list_ptr, GDestroyNotify destroy);
|
|||
void g_queue_clear_full (GQueue * queue, GDestroyNotify free_func);
|
||||
#endif /* ! GLIB_CHECK_VERSION (2, 60, 0) */
|
||||
|
||||
#if ! GLIB_CHECK_VERSION (2, 77, 0)
|
||||
GString *g_string_new_take (char *init);
|
||||
#endif /* ! GLIB_CHECK_VERSION (2, 77, 0) */
|
||||
|
||||
/* There is no such API in GLib2 */
|
||||
GString *mc_g_string_copy (GString * dest, const GString * src);
|
||||
|
||||
|
|
|
@ -873,7 +873,8 @@ edit_replace_cmd (WEdit * edit, gboolean again)
|
|||
edit->search = NULL;
|
||||
}
|
||||
|
||||
input2_str = g_string_new (input2);
|
||||
input2_str = g_string_new_take (input2);
|
||||
input2 = NULL;
|
||||
|
||||
if (edit->search == NULL)
|
||||
{
|
||||
|
|
|
@ -1015,8 +1015,7 @@ setup_cmdline (void)
|
|||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell)
|
||||
{
|
||||
subshell_prompt = g_string_new (tmp_prompt);
|
||||
g_free (tmp_prompt);
|
||||
subshell_prompt = g_string_new_take (tmp_prompt);
|
||||
mc_prompt = subshell_prompt->str;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2353,8 +2353,7 @@ goto_parent_dir (WPanel * panel)
|
|||
mc_build_filename (vfs_path_as_str (panel->panelized_descr->root_vpath), fname->str,
|
||||
(char *) NULL);
|
||||
|
||||
fname = g_string_new (fname2);
|
||||
g_free (fname2);
|
||||
fname = g_string_new_take (fname2);
|
||||
}
|
||||
|
||||
bname = x_basename (fname->str);
|
||||
|
@ -5243,8 +5242,7 @@ panel_panelize_cd (void)
|
|||
|
||||
tmp_vpath =
|
||||
vfs_path_append_new (pdescr->root_vpath, plist->list[i].fname->str, (char *) NULL);
|
||||
list->list[i].fname = g_string_new (vfs_path_as_str (tmp_vpath));
|
||||
vfs_path_free (tmp_vpath, TRUE);
|
||||
list->list[i].fname = g_string_new_take (vfs_path_free (tmp_vpath, FALSE));
|
||||
}
|
||||
list->list[i].f.link_to_dir = plist->list[i].f.link_to_dir;
|
||||
list->list[i].f.stale_link = plist->list[i].f.stale_link;
|
||||
|
|
|
@ -939,12 +939,14 @@ expand_format (const Widget * edit_widget, char c, gboolean do_quote)
|
|||
if (tmp != NULL)
|
||||
{
|
||||
if (block == NULL)
|
||||
block = g_string_new (tmp);
|
||||
block = g_string_new_take (tmp);
|
||||
else
|
||||
{
|
||||
g_string_append (block, tmp);
|
||||
g_string_append_c (block, ' ');
|
||||
g_free (tmp);
|
||||
}
|
||||
g_string_append_c (block, ' ');
|
||||
}
|
||||
|
||||
if (c_lc == 'u')
|
||||
do_file_mark (panel, i, 0);
|
||||
|
|
Loading…
Reference in New Issue