mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 19:52:48 +00:00
core: Merge malloc_trim patch
We've had multiple opportunities where Richard Mudgett's malloc_trim patch has been useful. Let's get it pushed up to gerrit and merged. Since malloc_trim is only available in libc, an entry is added to configure.ac to create a definition for HAVE_MALLOC_TRIM. Change-Id: Ia38308c550149d9d6eae4ca414a649957de9700c
This commit is contained in:
33
main/cli.c
33
main/cli.c
@@ -1779,6 +1779,34 @@ static char *handle_cli_wait_fullybooted(struct ast_cli_entry *e, int cmd, struc
|
||||
return CLI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_MALLOC_TRIM
|
||||
/* BUGBUG malloc_trim() is a libc specific function. Non-portable. */
|
||||
static char *handle_cli_malloc_trim(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||
{
|
||||
extern int malloc_trim(size_t __pad) __THROW;
|
||||
|
||||
switch (cmd) {
|
||||
case CLI_INIT:
|
||||
e->command = "malloc trim";
|
||||
e->usage =
|
||||
"Usage: malloc trim\n"
|
||||
" Try to give excess memory back to the OS.\n";
|
||||
return NULL;
|
||||
case CLI_GENERATE:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (malloc_trim(0)) {
|
||||
ast_cli(a->fd, "Returned some memory to the OS.\n");
|
||||
} else {
|
||||
ast_cli(a->fd, "No memory returned to the OS.\n");
|
||||
}
|
||||
|
||||
return CLI_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
static char *handle_help(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
|
||||
|
||||
static struct ast_cli_entry cli_cli[] = {
|
||||
@@ -1824,6 +1852,11 @@ static struct ast_cli_entry cli_cli[] = {
|
||||
AST_CLI_DEFINE(handle_cli_check_permissions, "Try a permissions config for a user"),
|
||||
|
||||
AST_CLI_DEFINE(handle_cli_wait_fullybooted, "Wait for Asterisk to be fully booted"),
|
||||
|
||||
#ifdef HAVE_MALLOC_TRIM
|
||||
AST_CLI_DEFINE(handle_cli_malloc_trim, "Return excess memory to the OS"),
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
|
Reference in New Issue
Block a user