mirror of
https://github.com/systemd/systemd.git
synced 2025-03-10 16:58:28 +03:00
shared/open-file: make open_file_free_many static inline
This commit is contained in:
parent
c642f43131
commit
4eb1feb110
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -122,21 +121,16 @@ int open_file_to_string(const OpenFile *of, char **ret) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenFile *open_file_free(OpenFile *of) {
|
OpenFile* open_file_free(OpenFile *of) {
|
||||||
if (!of)
|
if (!of)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
free(of->path);
|
free(of->path);
|
||||||
free(of->fdname);
|
free(of->fdname);
|
||||||
|
|
||||||
return mfree(of);
|
return mfree(of);
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_file_free_many(OpenFile **head) {
|
|
||||||
assert(head);
|
|
||||||
|
|
||||||
LIST_CLEAR(open_files, *head, open_file_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char * const open_file_flags_table[_OPENFILE_MAX] = {
|
static const char * const open_file_flags_table[_OPENFILE_MAX] = {
|
||||||
[OPENFILE_READ_ONLY] = "read-only",
|
[OPENFILE_READ_ONLY] = "read-only",
|
||||||
[OPENFILE_APPEND] = "append",
|
[OPENFILE_APPEND] = "append",
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
#include "macro.h"
|
||||||
|
|
||||||
typedef enum OpenFileFlag {
|
typedef enum OpenFileFlag {
|
||||||
OPENFILE_READ_ONLY = 1 << 0,
|
OPENFILE_READ_ONLY = 1 << 0,
|
||||||
@ -27,10 +27,12 @@ int open_file_validate(const OpenFile *of);
|
|||||||
|
|
||||||
int open_file_to_string(const OpenFile *of, char **ret);
|
int open_file_to_string(const OpenFile *of, char **ret);
|
||||||
|
|
||||||
OpenFile *open_file_free(OpenFile *of);
|
OpenFile* open_file_free(OpenFile *of);
|
||||||
DEFINE_TRIVIAL_CLEANUP_FUNC(OpenFile*, open_file_free);
|
DEFINE_TRIVIAL_CLEANUP_FUNC(OpenFile*, open_file_free);
|
||||||
|
|
||||||
void open_file_free_many(OpenFile **head);
|
static inline void open_file_free_many(OpenFile **head) {
|
||||||
|
LIST_CLEAR(open_files, *ASSERT_PTR(head), open_file_free);
|
||||||
|
}
|
||||||
|
|
||||||
const char *open_file_flags_to_string(OpenFileFlag t) _const_;
|
const char* open_file_flags_to_string(OpenFileFlag t) _const_;
|
||||||
OpenFileFlag open_file_flags_from_string(const char *t) _pure_;
|
OpenFileFlag open_file_flags_from_string(const char *t) _pure_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user