Module: sip-router
Branch: master
Commit: 5457bcbc51012e93775c3aaefa32c73f956aa279
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5457bcbc51012e93775c3aaefa32c73f956aa279

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Mon Apr 14 20:19:44 2014 +0200

lib/srdb1: clone db url in db_id structure

---

 lib/srdb1/db_id.c |    7 +++++--
 lib/srdb1/db_id.h |    1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/srdb1/db_id.c b/lib/srdb1/db_id.c
index 29b0226..d37e521 100644
--- a/lib/srdb1/db_id.c
+++ b/lib/srdb1/db_id.c
@@ -239,12 +239,12 @@ struct db_id* new_db_id(const str* url, db_pooling_t 
pooling)
                return 0;
        }
 
-       ptr = (struct db_id*)pkg_malloc(sizeof(struct db_id));
+       ptr = (struct db_id*)pkg_malloc(sizeof(struct db_id) + url->len + 1);
        if (!ptr) {
                LM_ERR("no private memory left\n");
                goto err;
        }
-       memset(ptr, 0, sizeof(struct db_id));
+       memset(ptr, 0, sizeof(struct db_id)+url->len+1);
 
        if (parse_db_url(ptr, url) < 0) {
                LM_ERR("error while parsing database URL: '%.*s' \n", url->len, 
url->s);
@@ -254,6 +254,9 @@ struct db_id* new_db_id(const str* url, db_pooling_t 
pooling)
        if (pooling == DB_POOLING_NONE) ptr->poolid = ++poolid;
        else ptr->poolid = 0;
        ptr->pid = my_pid();
+       ptr->url.len = url->len;
+       strncpy(ptr->url.s, url->s, url->len);
+       ptr->url.s[url->len] = '\0';
 
        return ptr;
 
diff --git a/lib/srdb1/db_id.h b/lib/srdb1/db_id.h
index 6d5a93f..ea312c9 100644
--- a/lib/srdb1/db_id.h
+++ b/lib/srdb1/db_id.h
@@ -35,6 +35,7 @@
 
 /** Structure representing a database ID */
 struct db_id {
+       str   url;           /**< full URL clone */
        char* scheme;        /**< URL scheme */
        char* username;      /**< Username, case sensitive */
        char* password;      /**< Password, case sensitive */


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to