]> git.ipfire.org Git - collecty.git/commitdiff
module: Format any arguments on the stack
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Sep 2025 15:25:16 +0000 (15:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Sep 2025 15:25:16 +0000 (15:25 +0000)
We seem to be keeping the allocator quite busy, which we don't need to
do too much.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/module.c

index 739fb8a1bbdd953638073581d0c80db8d10e244b..e56cf26fefbcdf5717641fd83f050fc49b95eb5e 100644 (file)
@@ -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);
 }