Module: kamailio
Branch: master
Commit: 1a20bcaa35db4aa80d6460dfb0fb9c70026248c9
URL:
https://github.com/kamailio/kamailio/commit/1a20bcaa35db4aa80d6460dfb0fb9c7…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-07-13T14:05:27+02:00
core: mem - added shm_address_in(p)
- return 1 if pointer p is inside shared memory zone, 0 otherwise
---
Modified: src/core/mem/shm.c
Modified: src/core/mem/shm.h
---
Diff:
https://github.com/kamailio/kamailio/commit/1a20bcaa35db4aa80d6460dfb0fb9c7…
Patch:
https://github.com/kamailio/kamailio/commit/1a20bcaa35db4aa80d6460dfb0fb9c7…
---
diff --git a/src/core/mem/shm.c b/src/core/mem/shm.c
index 3dbc34f11a..2cecb1110e 100644
--- a/src/core/mem/shm.c
+++ b/src/core/mem/shm.c
@@ -165,6 +165,28 @@ void* shm_core_get_pool(void)
return _shm_core_pools_mem[0];
}
+/**
+ *
+ */
+int shm_address_in(void *p)
+{
+ int i;
+
+ for(i = 0; i < _shm_core_pools_num; i++) {
+ if(_shm_core_pools_mem[i] == (void *)-1) {
+ continue;
+ }
+ if(((char*)p >= (char*)_shm_core_pools_mem[i])
+ && ((char*)p < ((char*)_shm_core_pools_mem[i]) + shm_mem_size)) {
+ /* address in shm zone */
+ return 1;
+ }
+ }
+
+ /* address not in shm zone */
+ return 0;
+}
+
/**
*
*/
diff --git a/src/core/mem/shm.h b/src/core/mem/shm.h
index 5d58071359..e36a94accc 100644
--- a/src/core/mem/shm.h
+++ b/src/core/mem/shm.h
@@ -86,6 +86,8 @@ int shm_init_manager(char *name);
void shm_destroy_manager(void);
void shm_print_manager(void);
+int shm_address_in(void *p);
+
#define shm_available_safe() shm_available()
#define shm_malloc_on_fork() do{}while(0)