mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
(mc_g_string_copy): new API that extends GString one.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
0acac06158
commit
01f096f52f
@ -160,3 +160,29 @@ g_queue_clear_full (GQueue * queue, GDestroyNotify free_func)
|
||||
#endif /* ! GLIB_CHECK_VERSION (2, 60, 0) */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* mc_g_string_copy:
|
||||
* @dest: (not nullable): the destination #GString. Its current contents are destroyed
|
||||
* @src: (not nullable): the source #GString
|
||||
* @return: @dest
|
||||
*
|
||||
* Copies the bytes from a #GString into a #GString, destroying any previous contents.
|
||||
* It is rather like the standard strcpy() function, except that you do not have to worry about
|
||||
* having enough space to copy the string.
|
||||
*
|
||||
* There is no such API in GLib2.
|
||||
*/
|
||||
GString *
|
||||
mc_g_string_copy (GString * dest, const GString * src)
|
||||
{
|
||||
g_return_val_if_fail (src != NULL, NULL);
|
||||
g_return_val_if_fail (dest != NULL, NULL);
|
||||
|
||||
g_string_set_size (dest, 0);
|
||||
g_string_append_len (dest, src->str, src->len);
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -24,6 +24,9 @@ void g_queue_free_full (GQueue * queue, GDestroyNotify free_func);
|
||||
void g_queue_clear_full (GQueue * queue, GDestroyNotify free_func);
|
||||
#endif /* ! GLIB_CHECK_VERSION (2, 60, 0) */
|
||||
|
||||
/* There is no such API in GLib2 */
|
||||
GString *mc_g_string_copy (GString * dest, const GString * src);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC_GLIBCOMPAT_H */
|
||||
|
Loading…
Reference in New Issue
Block a user