Module: kamailio
Branch: master
Commit: 22581f95690415681ea233c97923137e46fb55ae
URL:
https://github.com/kamailio/kamailio/commit/22581f95690415681ea233c97923137…
Author: Xenofon Karamanos <xk(a)gilawa.com>
Committer: Henning Westerholt <hw(a)gilawa.com>
Date: 2024-02-19T21:28:19+01:00
file_out: Free allocated memory
---
Modified: src/modules/file_out/file_out.c
Modified: src/modules/file_out/types.c
Modified: src/modules/file_out/types.h
---
Diff:
https://github.com/kamailio/kamailio/commit/22581f95690415681ea233c97923137…
Patch:
https://github.com/kamailio/kamailio/commit/22581f95690415681ea233c97923137…
---
diff --git a/src/modules/file_out/file_out.c b/src/modules/file_out/file_out.c
index fde63db5a0b..5a7643d0e4f 100644
--- a/src/modules/file_out/file_out.c
+++ b/src/modules/file_out/file_out.c
@@ -183,6 +183,16 @@ static void destroy(void)
ERR("Failed to close output file");
}
}
+
+ /* Free allocated mem */
+ if(fo_number_of_files != NULL) {
+ shm_free(fo_number_of_files);
+ fo_number_of_files = NULL;
+ }
+
+ if(fo_queue != NULL) {
+ fo_free_queue(fo_queue);
+ }
}
static void fo_log_writer_process(int rank)
diff --git a/src/modules/file_out/types.c b/src/modules/file_out/types.c
index d2815333dd0..f5c43a41695 100644
--- a/src/modules/file_out/types.c
+++ b/src/modules/file_out/types.c
@@ -113,3 +113,12 @@ int fo_queue_size(fo_queue_t *q)
lock_release(&(q->lock));
return count;
}
+
+void fo_free_queue(fo_queue_t *q)
+{
+ fo_log_message_t data;
+ while(fo_dequeue(q, &data) > 0) {
+ shm_free(data.message);
+ }
+ shm_free(q);
+}
diff --git a/src/modules/file_out/types.h b/src/modules/file_out/types.h
index c6fb72b28ef..b9c3b411165 100644
--- a/src/modules/file_out/types.h
+++ b/src/modules/file_out/types.h
@@ -43,3 +43,4 @@ int fo_enqueue(fo_queue_t *q, fo_log_message_t data);
int fo_dequeue(fo_queue_t *q, fo_log_message_t *data);
int fo_is_queue_empty(fo_queue_t *q);
int fo_queue_size(fo_queue_t *q);
+void fo_free_queue(fo_queue_t *q);