tree-wide: use newa() instead of alloca() wherever we can

Typesafety is nice. And this way we can take benefit of the new size
assert() the previous commit added.
This commit is contained in:
Lennart Poettering
2019-01-26 15:52:18 +01:00
parent 4aee28c67b
commit 6e9417f5b4
13 changed files with 22 additions and 20 deletions

View File

@@ -6,6 +6,7 @@
#include <stddef.h>
#include <string.h>
#include "alloc-util.h"
#include "macro.h"
/* What is interpreted as whitespace? */
@@ -111,7 +112,7 @@ char *strjoin_real(const char *x, ...) _sentinel_;
size_t _i_; \
for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \
_len_ += strlen(_appendees_[_i_]); \
_p_ = _d_ = alloca(_len_ + 1); \
_p_ = _d_ = newa(char, _len_ + 1); \
for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \
_p_ = stpcpy(_p_, _appendees_[_i_]); \
*_p_ = 0; \