[sr-dev] git:master:9100baa7: core: str - helerp macros to set str variable with char* value

Daniel-Constantin Mierla miconda at gmail.com
Thu May 12 18:20:07 CEST 2022


Module: kamailio
Branch: master
Commit: 9100baa7e3762b49a339933b2790a9d9cb1128c5
URL: https://github.com/kamailio/kamailio/commit/9100baa7e3762b49a339933b2790a9d9cb1128c5

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-05-12T13:51:52+02:00

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

---

Modified: src/core/str.h

---

Diff:  https://github.com/kamailio/kamailio/commit/9100baa7e3762b49a339933b2790a9d9cb1128c5.diff
Patch: https://github.com/kamailio/kamailio/commit/9100baa7e3762b49a339933b2790a9d9cb1128c5.patch

---

diff --git a/src/core/str.h b/src/core/str.h
index 063a9e9398..615b35499e 100644
--- a/src/core/str.h
+++ b/src/core/str.h
@@ -142,6 +142,22 @@ typedef struct _str str;
 		} \
 	} while(0)
 
+/**
+ * set str x variable with static value char* v
+ */
+#define STR_STATIC_SET(x, v) do { \
+	(x).s = v; \
+	(x).len = sizeof(v) - 1; \
+} while (0);
+
+/**
+ * set str x variable with char* v
+ */
+#define STR_SET(x, v) do { \
+	(x).s = v; \
+	(x).len = strlen(v); \
+} while (0);
+
 /**
  * str with value: not null and not empty
  */




More information about the sr-dev mailing list