]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared: Add a image_policy_copy() helper method
authorPhilip Withnall <pwithnall@gnome.org>
Fri, 29 May 2026 12:29:07 +0000 (13:29 +0100)
committerPhilip Withnall <pwithnall@gnome.org>
Fri, 26 Jun 2026 09:58:10 +0000 (10:58 +0100)
This will be used in an upcoming commit to move global command line
argument variables in sysupdate into its `Context` struct.

src/shared/image-policy.c
src/shared/image-policy.h

index 59d1161d04657af195884aca0b978ce6781e6f4b..622b5c2aa14b32b3ab875d0b50b2472309413b61 100644 (file)
@@ -948,6 +948,12 @@ ImagePolicy* image_policy_free(ImagePolicy *p) {
         return mfree(p);
 }
 
+ImagePolicy* image_policy_copy(const ImagePolicy *p) {
+        assert(p);
+
+        return memdup(p, offsetof(ImagePolicy, policies) + sizeof(PartitionPolicy) * p->n_policies);
+}
+
 int image_policy_ignore_designators(const ImagePolicy *p, const PartitionDesignator table[], size_t n_table, ImagePolicy **ret) {
         assert(p);
         assert(table || n_table == 0);
index fe2bf0d20041a6812de7093dac24577da9c13325..b0c229e71eabd5f3b94e3210de88c3b4c8eb582e 100644 (file)
@@ -119,6 +119,8 @@ ImagePolicy* image_policy_free(ImagePolicy *p);
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(ImagePolicy*, image_policy_free);
 
+ImagePolicy* image_policy_copy(const ImagePolicy *p);
+
 CONFIG_PARSER_PROTOTYPE(config_parse_image_policy);
 int parse_image_policy_argument(const char *s, ImagePolicy **policy);