]> git.ipfire.org Git - thirdparty/collectd.git/commit
Add scalloc() and use it in src/processes.c (#4014)
authorEero Tamminen <eero.t.tamminen@intel.com>
Wed, 8 Jun 2022 09:31:07 +0000 (12:31 +0300)
committerGitHub <noreply@github.com>
Wed, 8 Jun 2022 09:31:07 +0000 (11:31 +0200)
commitdfd034032b7c7c8f821774715c0723c42cefd332
treea007e6a3cc2a9dedb4ccaf4c2aa4a8cb44e66ffa
parentb4bdc7a8486683533185db34f97fd0f219fdc36b
Add scalloc() and use it in src/processes.c (#4014)

* Add scalloc() wrapper similar to smalloc() to common utils

scalloc() wraps calloc() with exit on alloc failure,
similarly to what smalloc() does for malloc().

* Handle (Solaris-only) ps_read_process calloc fails by using scalloc

Everything else checks and handles calloc failures except this function.

As I cannot test Solaris specific code, I've just replaced calloc with
scalloc, which gracefully exits collectd with error message on alloc
failures (instead of corrupting memory / crashing, as would happen
with current code).
src/processes.c
src/utils/common/common.c
src/utils/common/common.h