Module: kamailio
Branch: master
Commit: 3d2e26a7d5a1f16d0ff3af5a44cffe7b2622a6bf
URL: 
https://github.com/kamailio/kamailio/commit/3d2e26a7d5a1f16d0ff3af5a44cffe7b2622a6bf

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-07-13T08:31:45+02:00

core: helper function to get index of a char

---

Modified: src/core/ut.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/3d2e26a7d5a1f16d0ff3af5a44cffe7b2622a6bf.diff
Patch: 
https://github.com/kamailio/kamailio/commit/3d2e26a7d5a1f16d0ff3af5a44cffe7b2622a6bf.patch

---

diff --git a/src/core/ut.h b/src/core/ut.h
index 16bbde5d239..744b8f11afe 100644
--- a/src/core/ut.h
+++ b/src/core/ut.h
@@ -457,6 +457,19 @@ static inline char *q_memrchr(char *p, int c, unsigned int 
size)
        return 0;
 }
 
+/* index of the char */
+static inline int q_memidx(char *p, int c, unsigned int size)
+{
+       int i;
+
+       for(i = 0; i < (int)size; i++) {
+               if((unsigned char)p[i] == (unsigned char)c) {
+                       return i;
+               }
+       }
+       return -1;
+}
+
 /* returns -1 on error, 1! on success (consistent with int2reverse_hex) */
 inline static int reverse_hex2int(char *c, int len, unsigned int *res)
 {

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to