string-util: introduce strrepa

This commit is contained in:
Mike Yuan
2023-09-02 22:59:15 +08:00
parent 62efc7629b
commit 00614746e9
2 changed files with 19 additions and 0 deletions
+11
View File
@@ -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);