diff options
author | June McEnroe <june@causal.agency> | 2021-09-26 17:51:03 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-09-26 17:51:03 -0400 |
commit | 55c4755943e16a84b4bb7a6b1d9e4d70ac35728a (patch) | |
tree | 8de509bf4c8ac31b3dd7ec7ea9e1a3440b8909a4 /daemon.h | |
parent | Don't parse config until after daemonization (diff) | |
download | catsit-55c4755943e16a84b4bb7a6b1d9e4d70ac35728a.tar.gz catsit-55c4755943e16a84b4bb7a6b1d9e4d70ac35728a.zip |
Use reallocarray(3)
Diffstat (limited to '')
-rw-r--r-- | daemon.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/daemon.h b/daemon.h index e86e43a..fb58088 100644 --- a/daemon.h +++ b/daemon.h @@ -38,7 +38,9 @@ static inline void prependClear(void) { static inline int prependAdd(const char *command) { if (prepend.len == prepend.cap) { size_t cap = (prepend.cap ? prepend.cap * 2 : 8); - void *ptr = realloc(prepend.commands, sizeof(*prepend.commands) * cap); + void *ptr = reallocarray( + prepend.commands, cap, sizeof(*prepend.commands) + ); if (!ptr) return -1; prepend.cap = cap; prepend.commands = ptr; |