Skip to content

Commit

Permalink
mem: add rpm cli param for selecting allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Apr 3, 2019
1 parent 5ad04ac commit 3bce368
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions main.c
Expand Up @@ -108,6 +108,7 @@
#include "globals.h"
#include "mem/mem.h"
#include "mem/shm_mem.h"
#include "mem/rpm_mem.h"
#include "sr_module.h"
#include "timer.h"
#include "ipc.h"
Expand Down Expand Up @@ -962,6 +963,13 @@ int main(int argc, char** argv)
goto error00;
}
break;
case 'e':
if (set_rpm_mm(optarg) < 0) {
LM_ERR("current build does not support "
"this allocator (-e %s)\n", optarg);
goto error00;
}
break;
}
}

Expand Down Expand Up @@ -1011,6 +1019,7 @@ int main(int argc, char** argv)
case 'a':
case 'k':
case 's':
case 'e':
/* ignoring, parsed previously */
break;
case 'b':
Expand Down
14 changes: 14 additions & 0 deletions mem/rpm_mem.c
Expand Up @@ -39,6 +39,20 @@ enum osips_mm mem_allocator_rpm = MM_NONE;
unsigned long rpm_mem_size = 0;
char *rpm_mem_file = RESTART_PERSISTENCY_MEM_FILE;

int set_rpm_mm(const char *mm_name)
{
#ifdef INLINE_ALLOC
LM_NOTICE("this is an inlined allocator build (see opensips -V), "
"cannot set a custom rpm allocator (%s)\n", mm_name);
return 0;
#endif

if (parse_mm(mm_name, &mem_allocator_rpm) < 0)
return -1;

return 0;
}

#ifndef INLINE_ALLOC
#ifdef DBG_MALLOC
void *(*gen_rpm_malloc)(void *blk, unsigned long size,
Expand Down

0 comments on commit 3bce368

Please sign in to comment.