mirror of
https://github.com/systemd/systemd.git
synced 2026-08-02 22:20:20 +00:00
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:
@@ -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; \
|
||||
|
||||
Reference in New Issue
Block a user