diff options
author | Pavel Odintsov <odintsov@fastvps.ru> | 2015-12-28 14:08:57 +0300 |
---|---|---|
committer | Pavel Odintsov <odintsov@fastvps.ru> | 2015-12-28 14:08:57 +0300 |
commit | 1b2702df24ec06fa2cc244b350d96fdb3e8dd9e5 (patch) | |
tree | 5bcce4bef54c9a6ff077f46cc8056669f22c25ab | |
parent | 6d37ee2970c5866260a3fd66920a6bf6e740b702 (diff) |
Made ndpi memory allocator type compatible with C++ on x686 platforms. Switch from unsigned long to size_t as allocation functions parameter.
-rw-r--r-- | example/ndpiReader.c | 2 | ||||
-rw-r--r-- | src/include/ndpi_api.h | 6 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 10 |
3 files changed, 9 insertions, 9 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index e2cc162fb..b75672192 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -407,7 +407,7 @@ static void debug_printf(u_int32_t protocol, void *id_struct, /* ***************************************************** */ -static void *malloc_wrapper(unsigned long size) { +static void *malloc_wrapper(size_t size) { current_ndpi_memory += size; if(current_ndpi_memory > max_ndpi_memory) diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h index c788dcb29..86192c1fb 100644 --- a/src/include/ndpi_api.h +++ b/src/include/ndpi_api.h @@ -45,8 +45,8 @@ extern "C" { u_int32_t ndpi_detection_get_sizeof_ndpi_id_struct(void); /* Public malloc/free */ - void* ndpi_malloc(unsigned long size); - void* ndpi_calloc(unsigned long count, unsigned long size); + void* ndpi_malloc(size_t size); + void* ndpi_calloc(unsigned long count, size_t size); void ndpi_free(void *ptr); void *ndpi_realloc(void *ptr, size_t old_size, size_t new_size); char *ndpi_strdup(const char *s); @@ -75,7 +75,7 @@ extern "C" { * @return the initialized detection module */ struct ndpi_detection_module_struct *ndpi_init_detection_module(u_int32_t ticks_per_second, - void* (*__ndpi_malloc)(unsigned long size), + void* (*__ndpi_malloc)(size_t size), void (*__ndpi_free)(void *ptr), ndpi_debug_function_ptr ndpi_debug_printf); diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index dd5022b03..e9c3539a5 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -196,7 +196,7 @@ u_int8_t ndpi_ips_match(u_int32_t src, u_int32_t dst, /* ****************************************** */ -static void *(*_ndpi_malloc)(unsigned long size); +static void *(*_ndpi_malloc)(size_t size); static void (*_ndpi_free)(void *ptr); /* ****************************************** */ @@ -290,12 +290,12 @@ static int removeDefaultPort(ndpi_port_range *range, /* ****************************************** */ -void* ndpi_malloc(unsigned long size) { return(_ndpi_malloc(size)); } +void* ndpi_malloc(size_t size) { return(_ndpi_malloc(size)); } /* ****************************************** */ -void* ndpi_calloc(unsigned long count, unsigned long size) { - unsigned long len = count*size; +void* ndpi_calloc(unsigned long count, size_t size) { + size_t len = count*size; void *p = ndpi_malloc(len); if(p) @@ -1638,7 +1638,7 @@ static int ndpi_add_host_ip_subprotocol(struct ndpi_detection_module_struct *ndp /* ******************************************************************** */ struct ndpi_detection_module_struct *ndpi_init_detection_module(u_int32_t ticks_per_second, - void* (*__ndpi_malloc)(unsigned long size), + void* (*__ndpi_malloc)(size_t size), void (*__ndpi_free)(void *ptr), ndpi_debug_function_ptr ndpi_debug_printf) { |