]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Add dbus string convenience function _dbus_string_init_from_string().
authorRalf Habacker <ralf.habacker@freenet.de>
Fri, 5 Sep 2014 16:02:44 +0000 (18:02 +0200)
committerRalf Habacker <ralf.habacker@freenet.de>
Mon, 8 Sep 2014 12:00:42 +0000 (12:00 +0000)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=57272
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
dbus/dbus-string.c
dbus/dbus-string.h

index c4e2e7fcb2ed25b865cfe7e325dd4a619430fcc2..2001074084f336bfa47222c47650b665fa902de3 100644 (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().
  *
index 86fb8c39b48d9629b677fa635833727151ea45b2..44860feb49c11b5938316efa3cd18ee5f4c5dfb8 100644 (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,