Module: sip-router
Branch: master
Commit: 4bcc8357d12d1b2563cb3c7248804806c1ff4a9d
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4bcc835…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Tue Dec 2 16:05:48 2008 +0100
kamailio compatibility, add shm_strdup and pkg_strdup implementation
---
ut.h | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/ut.h b/ut.h
index e8ff01b..45cf559 100644
--- a/ut.h
+++ b/ut.h
@@ -61,6 +61,8 @@
#include "config.h"
#include "dprint.h"
#include "str.h"
+#include "mem/mem.h"
+#include "mem/shm_mem.h"
@@ -592,6 +594,45 @@ static inline int str2sint(str* _s, int* _r)
return 0;
}
+/**
+ * \brief Make a copy of a str structure using shm_malloc
+ * \param dst destination
+ * \param src source
+ * \return 0 on success, -1 on failure
+ */
+static inline int shm_str_dup(str* dst, const str* src)
+{
+ dst->s = shm_malloc(src->len);
+ if (!dst->s) {
+ SHM_MEM_ERROR;
+ return -1;
+ }
+
+ memcpy(dst->s, src->s, src->len);
+ dst->len = src->len;
+ return 0;
+}
+
+/**
+ * \brief Make a copy of a str structure using pkg_malloc
+ * \param dst destination
+ * \param src source
+ * \return 0 on success, -1 on failure
+ */
+static inline int pkg_str_dup(str* dst, const str* src)
+{
+ dst->s = pkg_malloc(src->len);
+ if (dst->s==NULL)
+ {
+ PKG_MEM_ERROR;
+ return -1;
+ }
+
+ memcpy(dst->s, src->s, src->len);
+ dst->len = src->len;
+ return 0;
+}
+
/* converts a username into uid:gid,
* returns -1 on error & 0 on success */
int user2uid(int* uid, int* gid, char* user);