pulse-server: add /core message handlers for memory debugging

Add malloc-info and malloc-trim message handlers.
This commit is contained in:
Wim Taymans 2023-10-06 16:49:03 +02:00
parent e8f17814ba
commit 4b27807292
2 changed files with 11 additions and 0 deletions

View file

@ -436,6 +436,7 @@ check_functions = [
['sigabbrev_np', '#include <string.h>', ['-D_GNU_SOURCE'], []],
['XSetIOErrorExitHandler', '#include <X11/Xlib.h>', [], [x11_dep]],
['malloc_trim', '#include <malloc.h>', [], []],
['malloc_info', '#include <malloc.h>', [], []],
]
foreach f : check_functions

View file

@ -6,6 +6,7 @@
#include <stdio.h>
#include <regex.h>
#include <malloc.h>
#include <spa/param/props.h>
#include <spa/pod/builder.h>
@ -104,6 +105,15 @@ static int core_object_message_handler(struct client *client, struct pw_manager_
}
}
fputc(']', response);
#ifdef HAVE_MALLOC_INFO
} else if (spa_streq(message, "malloc-info")) {
malloc_info(0, response);
#endif
#ifdef HAVE_MALLOC_TRIM
} else if (spa_streq(message, "malloc-trim")) {
int res = malloc_trim(0);
fprintf(response, "%d", res);
#endif
} else {
return -ENOSYS;
}