Add dbus string convenience function _dbus_string_init_from_string().

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=57272
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
This commit is contained in:
Ralf Habacker 2014-09-05 18:02:44 +02:00
parent 6c8b5ed056
commit 0cde94ecd9
2 changed files with 20 additions and 0 deletions

View file

@ -233,6 +233,23 @@ _dbus_string_init_const_len (DBusString *str,
*/
}
/**
* Initializes a string from another string. The
* string must eventually be freed with _dbus_string_free().
*
* @param str memory to hold the string
* @param from instance from which the string is initialized
* @returns #TRUE on success, #FALSE if no memory
*/
dbus_bool_t
_dbus_string_init_from_string(DBusString *str,
const DBusString *from)
{
if (!_dbus_string_init (str))
return FALSE;
return _dbus_string_append (str, _dbus_string_get_const_data (from));
}
/**
* Frees a string created by _dbus_string_init().
*

View file

@ -75,6 +75,9 @@ void _dbus_string_init_const_len (DBusString *str,
int len);
dbus_bool_t _dbus_string_init_preallocated (DBusString *str,
int allocate_size);
dbus_bool_t _dbus_string_init_from_string (DBusString *str,
const DBusString *from);
void _dbus_string_free (DBusString *str);
void _dbus_string_lock (DBusString *str);
dbus_bool_t _dbus_string_compact (DBusString *str,