[sr-dev] git:master:6684b576: core: utils - functions to shm-duplicate str in a block
Daniel-Constantin Mierla
miconda at gmail.com
Wed Jan 20 08:55:31 CET 2021
Module: kamailio
Branch: master
Commit: 6684b57641396ba494716e7f63a0f15afc1d8637
URL: https://github.com/kamailio/kamailio/commit/6684b57641396ba494716e7f63a0f15afc1d8637
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-01-19T21:00:54+01:00
core: utils - functions to shm-duplicate str in a block
---
Modified: src/core/ut.h
---
Diff: https://github.com/kamailio/kamailio/commit/6684b57641396ba494716e7f63a0f15afc1d8637.diff
Patch: https://github.com/kamailio/kamailio/commit/6684b57641396ba494716e7f63a0f15afc1d8637.patch
---
diff --git a/src/core/ut.h b/src/core/ut.h
index 0251fb7ca2..99e12a4136 100644
--- a/src/core/ut.h
+++ b/src/core/ut.h
@@ -745,6 +745,29 @@ static inline int strz2sint(char* _s, int* _r)
return 0;
}
+/**
+ * duplicate str structure and content in a single shm block
+ */
+static str* shm_str_dup_block(const str* src)
+{
+ str *dst;
+
+ if(src==NULL) {
+ return NULL;
+ }
+ dst = (str*)shm_malloc(sizeof(str) + src->len + 1);
+ if (dst == NULL) {
+ SHM_MEM_ERROR;
+ return NULL;
+ }
+ memset(dst, 0, sizeof(str) + src->len + 1);
+
+ dst->s = (char*)dst + sizeof(str);
+ dst->len = src->len;
+ memcpy(dst->s, src->s, src->len);
+
+ return dst;
+}
/**
* \brief Make a copy of a str structure to a str using shm_malloc
More information about the sr-dev
mailing list