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
861cb8c2
Unverified
Commit
861cb8c2
authored
Feb 05, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: remove stack allocations
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
57668944
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
22 deletions
+16
-22
cgfsng.c
src/lxc/cgroups/cgfsng.c
+16
-22
No files found.
src/lxc/cgroups/cgfsng.c
View file @
861cb8c2
...
...
@@ -58,6 +58,7 @@
#include "config.h"
#include "log.h"
#include "macro.h"
#include "memory_utils.h"
#include "storage/storage.h"
#include "utils.h"
...
...
@@ -888,15 +889,18 @@ static bool controller_in_clist(char *cgline, char *c)
return
false
;
len
=
eol
-
cgline
;
tmp
=
alloca
(
len
+
1
);
tmp
=
must_realloc
(
NULL
,
len
+
1
);
memcpy
(
tmp
,
cgline
,
len
);
tmp
[
len
]
=
'\0'
;
lxc_iterate_parts
(
tok
,
tmp
,
","
)
{
if
(
strcmp
(
tok
,
c
)
==
0
)
if
(
strcmp
(
tok
,
c
)
==
0
)
{
free
(
tmp
);
return
true
;
}
}
free
(
tmp
);
return
false
;
}
...
...
@@ -2209,15 +2213,12 @@ __cgfsng_ops static int cgfsng_get(struct cgroup_ops *ops, const char *filename,
char
*
value
,
size_t
len
,
const
char
*
name
,
const
char
*
lxcpath
)
{
int
ret
=
-
1
;
size_t
controller_len
;
char
*
controller
,
*
p
,
*
path
;
__do_free
char
*
controller
;
char
*
p
,
*
path
;
struct
hierarchy
*
h
;
int
ret
=
-
1
;
controller_len
=
strlen
(
filename
);
controller
=
alloca
(
controller_len
+
1
);
(
void
)
strlcpy
(
controller
,
filename
,
controller_len
+
1
);
controller
=
must_copy_string
(
filename
);
p
=
strchr
(
controller
,
'.'
);
if
(
p
)
*
p
=
'\0'
;
...
...
@@ -2248,15 +2249,12 @@ __cgfsng_ops static int cgfsng_set(struct cgroup_ops *ops,
const
char
*
filename
,
const
char
*
value
,
const
char
*
name
,
const
char
*
lxcpath
)
{
int
ret
=
-
1
;
size_t
controller_len
;
char
*
controller
,
*
p
,
*
path
;
__do_free
char
*
controller
;
char
*
p
,
*
path
;
struct
hierarchy
*
h
;
int
ret
=
-
1
;
controller_len
=
strlen
(
filename
);
controller
=
alloca
(
controller_len
+
1
);
(
void
)
strlcpy
(
controller
,
filename
,
controller_len
+
1
);
controller
=
must_copy_string
(
filename
);
p
=
strchr
(
controller
,
'.'
);
if
(
p
)
*
p
=
'\0'
;
...
...
@@ -2363,18 +2361,14 @@ out:
static
int
cg_legacy_set_data
(
struct
cgroup_ops
*
ops
,
const
char
*
filename
,
const
char
*
value
)
{
size_t
len
;
__do_free
char
*
controller
;
char
*
fullpath
,
*
p
;
/* "b|c <2^64-1>:<2^64-1> r|w|m" = 47 chars max */
char
converted_value
[
50
];
struct
hierarchy
*
h
;
int
ret
=
0
;
char
*
controller
=
NULL
;
len
=
strlen
(
filename
);
controller
=
alloca
(
len
+
1
);
(
void
)
strlcpy
(
controller
,
filename
,
len
+
1
);
controller
=
must_copy_string
(
filename
);
p
=
strchr
(
controller
,
'.'
);
if
(
p
)
*
p
=
'\0'
;
...
...
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