Cosmetic: Fixed captive_nv_printf_string_upper_bound(): +G_GNUC_UNUSED
authorshort <>
Sat, 11 Jan 2003 18:24:37 +0000 (18:24 +0000)
committershort <>
Sat, 11 Jan 2003 18:24:37 +0000 (18:24 +0000)
+captive_strdup_alloca()

src/libcaptive/include/captive/macros.h

index 39fe1b6..a6c82e1 100644 (file)
@@ -244,7 +244,7 @@ G_BEGIN_DECLS
                g_snprintf(_captive_printf_alloca_r,_captive_printf_alloca_size,(format) , ## args); \
                (const gchar *)_captive_printf_alloca_r; \
                })
-static inline gsize captive_nv_printf_string_upper_bound(const gchar *format,...) G_GNUC_PRINTF(1,0);
+static inline gsize captive_nv_printf_string_upper_bound(const gchar *format,...) G_GNUC_PRINTF(1,0) G_GNUC_UNUSED;
 static inline gsize captive_nv_printf_string_upper_bound(const gchar *format,...)
 {
 va_list ap;
@@ -257,6 +257,25 @@ gsize r;
 }
 
 
+/**
+ * captive_strdup_alloca:
+ * @string: #const #gchar * string to duplicate.
+ *
+ * Macro to do g_strdup() equivalent in g_alloca() style.
+ * 
+ * Memory is allocated on the stack frame by g_alloca() and it will be automatically deallocated
+ * during exit of current function (or current block if variable sized variables present there).
+ * You cannot deallocate or reallocate such memory in any other way.
+ *
+ * @Returns: Duplicated @string. You may modify its items if the length is not changed.
+ */
+#define captive_strdup_alloca(string) ({ \
+               const gchar *_captive_strdup_alloca_string=(string); \
+               gchar *_captive_strdup_alloca_r=g_alloca(strlen(_captive_strdup_alloca_string)+1); \
+               strcpy(_captive_strdup_alloca_r,_captive_strdup_alloca_string); \
+               (const gchar *)(_captive_strdup_alloca_string); \
+               })
+
 G_END_DECLS