]> git.sur5r.net Git - i3/i3/commitdiff
Introduce a function to copy i3strings
authorIngo Bürk <ingo.buerk@tngtech.com>
Sat, 21 Mar 2015 20:33:53 +0000 (21:33 +0100)
committerIngo Bürk <ingo.buerk@tngtech.com>
Mon, 23 Mar 2015 10:03:45 +0000 (11:03 +0100)
include/libi3.h
libi3/string.c

index c1a11dfc33ec7cef39b00310cbde3e07b99ff9f7..b60dda5c64ee2cc1a533b441ee11b5500bac36a6 100644 (file)
@@ -169,6 +169,12 @@ i3String *i3string_from_markup_with_length(const char *from_markup, size_t num_b
  */
 i3String *i3string_from_ucs2(const xcb_char2b_t *from_ucs2, size_t num_glyphs);
 
  */
 i3String *i3string_from_ucs2(const xcb_char2b_t *from_ucs2, size_t num_glyphs);
 
+/**
+ * Copies the given i3string.
+ * Note that this will not free the source string.
+ */
+i3String *i3string_copy(i3String *str);
+
 /**
  * Free an i3String.
  *
 /**
  * Free an i3String.
  *
index afeca9741c3fd4479278ce44dbad59180955d7a1..a28cc899195f8fc0bfe23b4f05a4caccc167b2d5 100644 (file)
@@ -109,6 +109,17 @@ i3String *i3string_from_ucs2(const xcb_char2b_t *from_ucs2, size_t num_glyphs) {
     return str;
 }
 
     return str;
 }
 
+/**
+ * Copies the given i3string.
+ * Note that this will not free the source string.
+ */
+i3String *i3string_copy(i3String *str) {
+    if (str->is_markup)
+        return i3string_from_markup(i3string_as_utf8(str));
+    else
+        return i3string_from_utf8(i3string_as_utf8(str));
+}
+
 /*
  * Free an i3String.
  *
 /*
  * Free an i3String.
  *