summaryrefslogtreecommitdiff
path: root/src/lib/eina/eina_slice.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/eina/eina_slice.h')
-rw-r--r--src/lib/eina/eina_slice.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/lib/eina/eina_slice.h b/src/lib/eina/eina_slice.h
index a354eaa566..6bb3aaa8bb 100644
--- a/src/lib/eina/eina_slice.h
+++ b/src/lib/eina/eina_slice.h
@@ -362,7 +362,7 @@ static inline char *eina_slice_strdup(const Eina_Slice slice);
/**
* @brief A null-terminated string for this slice.
*
- * @param[in] slice the reference memory.
+ * @param[in] rw_slice the reference memory.
* @return newly allocated memory or @c NULL on error
*
* @since 1.19
@@ -464,6 +464,30 @@ static inline char *eina_rw_slice_strdup(const Eina_Rw_Slice rw_slice);
#else
#define EINA_SLICE_STR(str) {.len = strlen((str)), .mem = (str)}
#endif
+/**
+ * @def EINA_SLICE_STR_FULL(str)
+ *
+ * Same as EINA_SLICE_STR_FULL, but it also contains the \0 element of the string
+ *
+ * @param[in] str The string to create the slice from.
+ * @return The initialized slice object.
+ *
+ * @note This macro is usable with both Eina_Slice or Eina_Rw_Slice.
+ *
+ * @code
+ * Eina_Slice ro_slice = EINA_SLICE_STR_FULL("hello world");
+ * @endcode
+ *
+ * @see EINA_SLICE_STR_FULL() for specific version using literals.
+ *
+ * @since 1.24
+ */
+#ifdef __cplusplus
+#define EINA_SLICE_STR_FULL(str) {strlen((str)) + 1, (str)}
+#else
+#define EINA_SLICE_STR_FULL(str) {.len = strlen((str)) + 1, .mem = (str)}
+#endif
+
/**
* @def EINA_SLICE_STR_FMT