diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-11-25 10:25:03 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-11-25 14:22:31 +0100 |
commit | 0cdf6b14a5389fdeb75d67dde42c88de75962956 (patch) | |
tree | d9b3053975fd55469eb8954be7537fe911d2ad6c /src/core | |
parent | e2c7efd3293c6a14cd6d5baf8e0898da9a5c6d96 (diff) | |
download | systemd-0cdf6b14a5389fdeb75d67dde42c88de75962956.tar.gz |
json: add new JSON_BUILD_CONST_STRING() macro
This macro is like JSON_BUILD_STRING() but uses our json library's
ability to use literal strings directly as JsonVariant objects.
The changes all our codebase to use this new macro whenever we build
JSON objects from literal strings.
(I tried to make this automatic, i.e. to detect in JSON_BUILD_STRING()
whether something is a literal string nicely and thus do this stuff
automatically, but I couldn't find a way.)
This should reduce memory usage of our JSON code a bit. Constant strings
we use very often will now be shared and mapped directly from the ELF
image.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/core-varlink.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/core-varlink.c b/src/core/core-varlink.c index 8c54cc0663..a75f9fb66f 100644 --- a/src/core/core-varlink.c +++ b/src/core/core-varlink.c @@ -31,12 +31,12 @@ static int build_user_json(const char *user_name, uid_t uid, JsonVariant **ret) JSON_BUILD_PAIR("userName", JSON_BUILD_STRING(user_name)), JSON_BUILD_PAIR("uid", JSON_BUILD_UNSIGNED(uid)), JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(uid)), - JSON_BUILD_PAIR("realName", JSON_BUILD_STRING("Dynamic User")), - JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_STRING("/")), - JSON_BUILD_PAIR("shell", JSON_BUILD_STRING(NOLOGIN)), + JSON_BUILD_PAIR("realName", JSON_BUILD_CONST_STRING("Dynamic User")), + JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")), + JSON_BUILD_PAIR("shell", JSON_BUILD_CONST_STRING(NOLOGIN)), JSON_BUILD_PAIR("locked", JSON_BUILD_BOOLEAN(true)), - JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.DynamicUser")), - JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("dynamic")))))); + JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.DynamicUser")), + JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic")))))); } static bool user_match_lookup_parameters(LookupParameters *p, const char *name, uid_t uid) { @@ -339,10 +339,10 @@ static int build_group_json(const char *group_name, gid_t gid, JsonVariant **ret return json_build(ret, JSON_BUILD_OBJECT( JSON_BUILD_PAIR("record", JSON_BUILD_OBJECT( JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(group_name)), - JSON_BUILD_PAIR("description", JSON_BUILD_STRING("Dynamic Group")), + JSON_BUILD_PAIR("description", JSON_BUILD_CONST_STRING("Dynamic Group")), JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(gid)), - JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.DynamicUser")), - JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("dynamic")))))); + JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.DynamicUser")), + JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic")))))); } static bool group_match_lookup_parameters(LookupParameters *p, const char *name, gid_t gid) { |