aboutsummaryrefslogtreecommitdiff
path: root/src/include/ndpi_api.h
diff options
context:
space:
mode:
authorVito Piserchia <vito.piserchia@dreamlab.net>2017-03-16 17:32:38 +0100
committerVito Piserchia <vito.piserchia@dreamlab.net>2017-03-16 17:35:10 +0100
commit4300208642e0ccd4d945a25e738b65d019b2cc30 (patch)
tree3a7aa5e85305d3eaf9dbef47d9cff9b8a6223d4a /src/include/ndpi_api.h
parent149818671d0cfcf09e37588aee963adc056f4250 (diff)
Added ndpi_flow_ free/malloc and set_ functions:
Ideally these two new functions will provide more flexibility in regards of application that want to use specific allocation approaches, for example storage queues for this structures from where the application can pop and release the data it needs. Semantically they can be set up as the other ndpi_malloc and ndpi_free functions, that is via the set_ndpi_flow_malloc and set_ndpi_flow_free. In case a NULL parameter is passed to the above functions the old approach will be used, that means that the ndpi_malloc will be used as the ndpi_flow_malloc function and ndpi_free_flow as the ndpi_flow_free one. Application that use the old functions will be not affected by this change, and the ndpi_free_flow can be deprecated in the future and made private.
Diffstat (limited to 'src/include/ndpi_api.h')
-rw-r--r--src/include/ndpi_api.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h
index ca295b4e1..bcc5fe51f 100644
--- a/src/include/ndpi_api.h
+++ b/src/include/ndpi_api.h
@@ -31,6 +31,9 @@
extern "C" {
#endif
+#define SIZEOF_ID_STRUCT (sizeof(struct ndpi_id_struct))
+#define SIZEOF_FLOW_STRUCT (sizeof(struct ndpi_flow_struct))
+
#define NDPI_DETECTION_ONLY_IPV4 ( 1 << 0 )
#define NDPI_DETECTION_ONLY_IPV6 ( 1 << 1 )
@@ -79,8 +82,9 @@ extern "C" {
void * ndpi_realloc(void *ptr, size_t old_size, size_t new_size);
char * ndpi_strdup(const char *s);
void ndpi_free(void *ptr);
+ void * ndpi_flow_malloc(size_t size);
+ void ndpi_flow_free(void *ptr);
-
/**
* Search the first occurrence of substring -find- in -s-
* The search is limited to the first -slen- characters of the string
@@ -591,6 +595,8 @@ extern "C" {
/* Utility functions to set ndpi malloc/free/print wrappers */
void set_ndpi_malloc(void* (*__ndpi_malloc)(size_t size));
void set_ndpi_free(void (*__ndpi_free)(void *ptr));
+ void set_ndpi_flow_malloc(void* (*__ndpi_flow_malloc)(size_t size));
+ void set_ndpi_flow_free(void (*__ndpi_flow_free)(void *ptr));
void set_ndpi_debug_function(struct ndpi_detection_module_struct *ndpi_str, ndpi_debug_function_ptr ndpi_debug_printf);
#ifdef __cplusplus