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
6e87cb17
Unverified
Commit
6e87cb17
authored
Mar 15, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
memory_utils: adapt to new infrastructure
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
5a076633
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
34 deletions
+24
-34
memory_utils.h
src/lxc/memory_utils.h
+24
-34
No files found.
src/lxc/memory_utils.h
View file @
6e87cb17
...
...
@@ -21,16 +21,37 @@
#define call_cleaner(cleaner) __attribute__((__cleanup__(cleaner##_function)))
#define close_prot_errno_disarm(fd) \
if (fd >= 0) { \
int _e_ = errno; \
close(fd); \
errno = _e_; \
fd = -EBADF; \
}
static
inline
void
close_prot_errno_disarm_function
(
int
*
fd
)
{
close_prot_errno_disarm
(
*
fd
);
}
#define __do_close_prot_errno call_cleaner(close_prot_errno_disarm)
define_cleanup_function
(
FILE
*
,
fclose
);
#define __do_fclose call_cleaner(fclose)
define_cleanup_function
(
DIR
*
,
closedir
);
#define __do_closedir call_cleaner(closedir)
#define free_disarm(ptr) \
({ \
free(ptr); \
move_ptr(ptr); \
})
static
inline
void
__auto_free__
(
void
*
p
)
static
inline
void
free_disarm_function
(
void
*
ptr
)
{
free
(
*
(
void
**
)
p
);
free
_disarm
(
*
(
void
**
)
ptr
);
}
#define __do_free call_cleaner(free_disarm)
static
inline
void
free_string_list
(
char
**
list
)
{
...
...
@@ -41,38 +62,7 @@ static inline void free_string_list(char **list)
}
}
define_cleanup_function
(
char
**
,
free_string_list
);
#define __do_free_string_list \
__attribute__((__cleanup__(free_string_list_function)))
static
inline
void
__auto_fclose__
(
FILE
**
f
)
{
if
(
*
f
)
fclose
(
*
f
);
}
static
inline
void
__auto_closedir__
(
DIR
**
d
)
{
if
(
*
d
)
closedir
(
*
d
);
}
#define close_prot_errno_disarm(fd) \
if (fd >= 0) { \
int _e_ = errno; \
close(fd); \
errno = _e_; \
fd = -EBADF; \
}
static
inline
void
__auto_close__
(
int
*
fd
)
{
close_prot_errno_disarm
(
*
fd
);
}
#define __do_close_prot_errno __attribute__((__cleanup__(__auto_close__)))
#define __do_free __attribute__((__cleanup__(__auto_free__)))
#define __do_fclose __attribute__((__cleanup__(__auto_fclose__)))
#define __do_closedir __attribute__((__cleanup__(__auto_closedir__)))
#define __do_free_string_list call_cleaner(free_string_list)
static
inline
void
*
memdup
(
const
void
*
data
,
size_t
len
)
{
...
...
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