Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
99b7f9db
Unverified
Commit
99b7f9db
authored
Jul 18, 2018
by
Wolfgang Bumiller
Committed by
Christian Brauner
Jul 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add must_concat helper
Signed-off-by:
Wolfgang Bumiller
<
w.bumiller@proxmox.com
>
parent
f6eea250
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
utils.c
src/lxc/utils.c
+24
-0
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/utils.c
View file @
99b7f9db
...
...
@@ -2426,6 +2426,30 @@ int run_command(char *buf, size_t buf_size, int (*child_fn)(void *), void *args)
return
fret
;
}
char
*
must_concat
(
const
char
*
first
,
...)
{
va_list
args
;
char
*
cur
,
*
dest
;
size_t
cur_len
,
it_len
;
dest
=
must_copy_string
(
first
);
cur_len
=
it_len
=
strlen
(
first
);
va_start
(
args
,
first
);
while
((
cur
=
va_arg
(
args
,
char
*
))
!=
NULL
)
{
it_len
=
strlen
(
cur
);
dest
=
must_realloc
(
dest
,
cur_len
+
it_len
+
1
);
(
void
)
memcpy
(
dest
+
cur_len
,
cur
,
it_len
);
cur_len
+=
it_len
;
}
va_end
(
args
);
dest
[
cur_len
]
=
0
;
return
dest
;
}
char
*
must_make_path
(
const
char
*
first
,
...)
{
va_list
args
;
...
...
src/lxc/utils.h
View file @
99b7f9db
...
...
@@ -567,6 +567,7 @@ extern int run_command(char *buf, size_t buf_size, int (*child_fn)(void *),
/* Concatenate all passed-in strings into one path. Do not fail. If any piece
* is not prefixed with '/', add a '/'.
*/
__attribute__
((
sentinel
))
extern
char
*
must_concat
(
const
char
*
first
,
...);
__attribute__
((
sentinel
))
extern
char
*
must_make_path
(
const
char
*
first
,
...);
__attribute__
((
sentinel
))
extern
char
*
must_append_path
(
char
*
first
,
...);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment