aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2021-01-03 13:54:47 +0100
committerToni Uhlig <matzeton@googlemail.com>2021-01-03 13:54:47 +0100
commit29f34a17a93c05d4ce2bdfbed51cb612ce413d34 (patch)
tree5af669784467b98f5d4be9b09e0b08d7e0ef20e2
parenta91e6179c5e19cd7769247614680a5e99f1b7cfc (diff)
Added a new API function `ndpi_free_flow_data' which free's all members of ndpi_flow_struct but not the struct itself.add/free-flow-data-api-fn
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--src/include/ndpi_api.h.in10
-rw-r--r--src/lib/ndpi_main.c7
2 files changed, 15 insertions, 2 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in
index d6145e99a..593cee4f3 100644
--- a/src/include/ndpi_api.h.in
+++ b/src/include/ndpi_api.h.in
@@ -203,7 +203,15 @@ extern "C" {
/**
* Frees the memory allocated in the specified flow
*
- * @par flow = the flow to deallocate
+ * @par flow = the flow struct which dynamic allocated members should be deallocated
+ *
+ */
+ void ndpi_free_flow_data(struct ndpi_flow_struct *flow);
+
+ /**
+ * Frees the memory allocated in the specified flow and the flow struct itself
+ *
+ * @par flow = the flow struct and its dynamic allocated members should be deallocated
*
*/
void ndpi_free_flow(struct ndpi_flow_struct *flow);
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 3309e6105..06a14d4e5 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -6310,7 +6310,7 @@ int ndpi_match_bigram(struct ndpi_detection_module_struct *ndpi_str,
/* ****************************************************** */
-void ndpi_free_flow(struct ndpi_flow_struct *flow) {
+void ndpi_free_flow_data(struct ndpi_flow_struct *flow) {
if(flow) {
u_int is_quic = flow_is_proto(flow, NDPI_PROTOCOL_QUIC);
@@ -6355,7 +6355,12 @@ void ndpi_free_flow(struct ndpi_flow_struct *flow) {
if(flow->l4.tcp.tls.message.buffer)
ndpi_free(flow->l4.tcp.tls.message.buffer);
}
+ }
+}
+void ndpi_free_flow(struct ndpi_flow_struct *flow) {
+ if (flow) {
+ ndpi_free_flow_data(flow);
ndpi_free(flow);
}
}