mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 00:47:10 +09:00
string-util: introduce strprepend() helper
This commit is contained in:
@@ -46,6 +46,20 @@ char* first_word(const char *s, const char *word) {
|
||||
return (char*) nw;
|
||||
}
|
||||
|
||||
char* strprepend(char **x, const char *s) {
|
||||
assert(x);
|
||||
|
||||
if (isempty(s) && *x)
|
||||
return *x;
|
||||
|
||||
char *p = strjoin(strempty(s), *x);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
free_and_replace(*x, p);
|
||||
return *x;
|
||||
}
|
||||
|
||||
char* strnappend(const char *s, const char *suffix, size_t b) {
|
||||
size_t a;
|
||||
char *r;
|
||||
|
||||
Reference in New Issue
Block a user