Browse code

core: str - helerp macros to set str variable with char* value

Daniel-Constantin Mierla authored on 12/05/2022 11:51:52
Showing 1 changed files
... ...
@@ -142,6 +142,22 @@ typedef struct _str str;
142 142
 		} \
143 143
 	} while(0)
144 144
 
145
+/**
146
+ * set str x variable with static value char* v
147
+ */
148
+#define STR_STATIC_SET(x, v) do { \
149
+	(x).s = v; \
150
+	(x).len = sizeof(v) - 1; \
151
+} while (0);
152
+
153
+/**
154
+ * set str x variable with char* v
155
+ */
156
+#define STR_SET(x, v) do { \
157
+	(x).s = v; \
158
+	(x).len = strlen(v); \
159
+} while (0);
160
+
145 161
 /**
146 162
  * str with value: not null and not empty
147 163
  */