Module: sip-router
Branch: tmp/ims_usrloc_pcscf_db_support
Commit: 57b824602fbd4c5c03ec5ce00d33b9e4a0accd9d
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=57b8246…
Author: Jason Penton <jason.penton(a)gmail.com>
Committer: Jason Penton <jason.penton(a)gmail.com>
Date: Fri Nov 29 11:50:39 2013 +0200
modules/ims_usrloc_pcscf: free pkg memory for reusable buffers
---
modules/ims_usrloc_pcscf/ul_mod.c | 3 +++
modules/ims_usrloc_pcscf/usrloc_db.c | 19 ++++++++++++++++++-
modules/ims_usrloc_pcscf/usrloc_db.h | 3 +++
3 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/modules/ims_usrloc_pcscf/ul_mod.c b/modules/ims_usrloc_pcscf/ul_mod.c
index d6cda13..fd6aeb2 100644
--- a/modules/ims_usrloc_pcscf/ul_mod.c
+++ b/modules/ims_usrloc_pcscf/ul_mod.c
@@ -263,6 +263,9 @@ static void destroy(void)
/* free callbacks list */
destroy_ulcb_list();
+ free_service_route_buf();
+ free_impu_buf();
+
if (db_mode)
destroy_db();
}
diff --git a/modules/ims_usrloc_pcscf/usrloc_db.c b/modules/ims_usrloc_pcscf/usrloc_db.c
index 7d55df3..4a2a416 100644
--- a/modules/ims_usrloc_pcscf/usrloc_db.c
+++ b/modules/ims_usrloc_pcscf/usrloc_db.c
@@ -26,7 +26,6 @@ str public_ids_col = str_init(PUBLIC_IDS_COL);
t_reusable_buffer service_route_buffer = {0,0,0};
t_reusable_buffer impu_buffer = {0,0,0};
-//char buf[2048];
int connect_db(const str *db_url)
{
@@ -378,4 +377,22 @@ int service_routes_as_string(struct pcontact* _c, t_reusable_buffer
*buffer) {
return len;
}
+void free_service_route_buf(void)
+{
+ if (service_route_buffer.buf) {
+ pkg_free(service_route_buffer.buf);
+ service_route_buffer.data_len = 0;
+ service_route_buffer.buf_len = 0;
+ service_route_buffer.buf = 0;
+ }
+}
+
+void free_impu_buf(void) {
+ if (impu_buffer.buf) {
+ pkg_free(impu_buffer.buf);
+ impu_buffer.data_len = 0;
+ impu_buffer.buf_len = 0;
+ impu_buffer.buf = 0;
+ }
+}
diff --git a/modules/ims_usrloc_pcscf/usrloc_db.h b/modules/ims_usrloc_pcscf/usrloc_db.h
index 61869f2..fbe8e28 100644
--- a/modules/ims_usrloc_pcscf/usrloc_db.h
+++ b/modules/ims_usrloc_pcscf/usrloc_db.h
@@ -96,6 +96,9 @@ int connect_db(const str *db_url);
int impus_as_string(struct pcontact* _c, t_reusable_buffer* buffer);
int service_routes_as_string(struct pcontact* _c, t_reusable_buffer *buffer);
+void free_service_route_buf(void);
+void free_impu_buf(void);
+
int db_insert_pcontact(pcontact_t* _c);
int db_delete_pcontact(pcontact_t* _c);
int db_update_pcontact(pcontact_t* _c);