mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
sysv-generator: introduce hash_ops for SysvStub
This also renames free_sysvstub() -> sysvstub_free(), to follow our usual coding style.
This commit is contained in:
@@ -64,7 +64,7 @@ typedef struct SysvStub {
|
||||
bool loaded;
|
||||
} SysvStub;
|
||||
|
||||
static SysvStub* free_sysvstub(SysvStub *s) {
|
||||
static SysvStub* sysvstub_free(SysvStub *s) {
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
@@ -78,11 +78,12 @@ static SysvStub* free_sysvstub(SysvStub *s) {
|
||||
strv_free(s->wanted_by);
|
||||
return mfree(s);
|
||||
}
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(SysvStub*, free_sysvstub);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(SysvStub*, sysvstub_free);
|
||||
|
||||
static void free_sysvstub_hashmapp(Hashmap **h) {
|
||||
hashmap_free_with_destructor(*h, free_sysvstub);
|
||||
}
|
||||
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
|
||||
sysvstub_hash_ops,
|
||||
char, string_hash_func, string_compare_func,
|
||||
SysvStub, sysvstub_free);
|
||||
|
||||
static int add_alias(const char *service, const char *alias) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
@@ -728,7 +729,7 @@ static int enumerate_sysv(const LookupPaths *lp, Hashmap *all_services) {
|
||||
|
||||
FOREACH_DIRENT(de, d, log_error_errno(errno, "Failed to enumerate directory %s, ignoring: %m", *path)) {
|
||||
_cleanup_free_ char *fpath = NULL, *name = NULL;
|
||||
_cleanup_(free_sysvstubp) SysvStub *service = NULL;
|
||||
_cleanup_(sysvstub_freep) SysvStub *service = NULL;
|
||||
struct stat st;
|
||||
|
||||
if (fstatat(dirfd(d), de->d_name, &st, 0) < 0) {
|
||||
@@ -894,7 +895,7 @@ finish:
|
||||
}
|
||||
|
||||
static int run(const char *dest, const char *dest_early, const char *dest_late) {
|
||||
_cleanup_(free_sysvstub_hashmapp) Hashmap *all_services = NULL;
|
||||
_cleanup_hashmap_free_ Hashmap *all_services = NULL;
|
||||
_cleanup_(lookup_paths_done) LookupPaths lp = {};
|
||||
SysvStub *service;
|
||||
int r;
|
||||
@@ -910,7 +911,7 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
all_services = hashmap_new(&string_hash_ops);
|
||||
all_services = hashmap_new(&sysvstub_hash_ops);
|
||||
if (!all_services)
|
||||
return log_oom();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user