From a840508ac80fa74c555d2f9e7559905ada8f1955 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 27 Sep 2025 15:25:16 +0000 Subject: [PATCH] module: Format any arguments on the stack We seem to be keeping the allocator quite busy, which we don't need to do too much. Signed-off-by: Michael Tremer --- src/daemon/module.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/daemon/module.c b/src/daemon/module.c index 739fb8a..e56cf26 100644 --- a/src/daemon/module.c +++ b/src/daemon/module.c @@ -225,13 +225,13 @@ const char* collecty_module_name(collecty_module* self) { */ int collecty_module_submit(collecty_module* self, const char* object, const char* format, ...) { - char* value = NULL; + char value[2048]; va_list args; int r; // Format the arguments va_start(args, format); - r = vasprintf(&value, format, args); + r = vsnprintf(value, sizeof(value), format, args); va_end(args); // Handle errors @@ -239,10 +239,5 @@ int collecty_module_submit(collecty_module* self, return -errno; // Submit the data to the daemon - r = collecty_daemon_submit(self->daemon, self, object, value); - - if (value) - free(value); - - return 0; + return collecty_daemon_submit(self->daemon, self, object, value); } -- 2.47.3