string-util: introduce strrepa
This commit is contained in:
@@ -196,6 +196,17 @@ int strextendf_with_separator(char **x, const char *separator, const char *forma
|
||||
|
||||
char *strrep(const char *s, unsigned n);
|
||||
|
||||
#define strrepa(s, n) \
|
||||
({ \
|
||||
char *_d_, *_p_; \
|
||||
size_t _len_ = strlen(s) * n; \
|
||||
_p_ = _d_ = newa(char, _len_ + 1); \
|
||||
for (unsigned _i_ = 0; _i_ < n; _i_++) \
|
||||
_p_ = stpcpy(_p_, s); \
|
||||
*_p_ = 0; \
|
||||
_d_; \
|
||||
})
|
||||
|
||||
int split_pair(const char *s, const char *sep, char **l, char **r);
|
||||
|
||||
int free_and_strdup(char **p, const char *s);
|
||||
|
||||
Reference in New Issue
Block a user