diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/basic-pass-allocation-info-for-ordered-set-new-and-introd.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/basic-pass-allocation-info-for-ordered-set-new-and-introd.patch | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/basic-pass-allocation-info-for-ordered-set-new-and-introd.patch b/meta/recipes-core/systemd/systemd/basic-pass-allocation-info-for-ordered-set-new-and-introd.patch new file mode 100644 index 0000000000..86d9b0499a --- /dev/null +++ b/meta/recipes-core/systemd/systemd/basic-pass-allocation-info-for-ordered-set-new-and-introd.patch | |||
@@ -0,0 +1,78 @@ | |||
1 | From 1f25c71d9d0b5fe6cf383c347dcebc2443a99fe1 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl> | ||
3 | Date: Tue, 1 Sep 2020 12:42:35 +0200 | ||
4 | Subject: [PATCH] basic: pass allocation info for ordered_set_new() and | ||
5 | introduce ordered_set_ensure_put() | ||
6 | |||
7 | Upstream-Status: Backport [https://github.com/systemd/systemd-stable/commit/1f25c71d9d0b5fe6cf383c347dcebc2443a99fe1] | ||
8 | Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com> | ||
9 | |||
10 | --- | ||
11 | src/basic/ordered-set.c | 21 +++++++++++++++++++++ | ||
12 | src/basic/ordered-set.h | 18 +++++++----------- | ||
13 | 2 files changed, 28 insertions(+), 11 deletions(-) | ||
14 | |||
15 | diff --git a/src/basic/ordered-set.c b/src/basic/ordered-set.c | ||
16 | index 7fdb47e064..fb82c17b5a 100644 | ||
17 | --- a/src/basic/ordered-set.c | ||
18 | +++ b/src/basic/ordered-set.c | ||
19 | @@ -4,6 +4,27 @@ | ||
20 | #include "ordered-set.h" | ||
21 | #include "strv.h" | ||
22 | |||
23 | +int _ordered_set_ensure_allocated(OrderedSet **s, const struct hash_ops *ops HASHMAP_DEBUG_PARAMS) { | ||
24 | + if (*s) | ||
25 | + return 0; | ||
26 | + | ||
27 | + *s = _ordered_set_new(ops HASHMAP_DEBUG_PASS_ARGS); | ||
28 | + if (!*s) | ||
29 | + return -ENOMEM; | ||
30 | + | ||
31 | + return 0; | ||
32 | +} | ||
33 | + | ||
34 | +int _ordered_set_ensure_put(OrderedSet **s, const struct hash_ops *ops, void *p HASHMAP_DEBUG_PARAMS) { | ||
35 | + int r; | ||
36 | + | ||
37 | + r = _ordered_set_ensure_allocated(s, ops HASHMAP_DEBUG_PASS_ARGS); | ||
38 | + if (r < 0) | ||
39 | + return r; | ||
40 | + | ||
41 | + return ordered_set_put(*s, p); | ||
42 | +} | ||
43 | + | ||
44 | int ordered_set_consume(OrderedSet *s, void *p) { | ||
45 | int r; | ||
46 | |||
47 | diff --git a/src/basic/ordered-set.h b/src/basic/ordered-set.h | ||
48 | index a42a57eb49..2c241a808b 100644 | ||
49 | --- a/src/basic/ordered-set.h | ||
50 | +++ b/src/basic/ordered-set.h | ||
51 | @@ -7,20 +7,16 @@ | ||
52 | |||
53 | typedef struct OrderedSet OrderedSet; | ||
54 | |||
55 | -static inline OrderedSet* ordered_set_new(const struct hash_ops *ops) { | ||
56 | - return (OrderedSet*) ordered_hashmap_new(ops); | ||
57 | +static inline OrderedSet* _ordered_set_new(const struct hash_ops *ops HASHMAP_DEBUG_PARAMS) { | ||
58 | + return (OrderedSet*) internal_ordered_hashmap_new(ops HASHMAP_DEBUG_PASS_ARGS); | ||
59 | } | ||
60 | +#define ordered_set_new(ops) _ordered_set_new(ops HASHMAP_DEBUG_SRC_ARGS) | ||
61 | |||
62 | -static inline int ordered_set_ensure_allocated(OrderedSet **s, const struct hash_ops *ops) { | ||
63 | - if (*s) | ||
64 | - return 0; | ||
65 | +int _ordered_set_ensure_allocated(OrderedSet **s, const struct hash_ops *ops HASHMAP_DEBUG_PARAMS); | ||
66 | +#define ordered_set_ensure_allocated(s, ops) _ordered_set_ensure_allocated(s, ops HASHMAP_DEBUG_SRC_ARGS) | ||
67 | |||
68 | - *s = ordered_set_new(ops); | ||
69 | - if (!*s) | ||
70 | - return -ENOMEM; | ||
71 | - | ||
72 | - return 0; | ||
73 | -} | ||
74 | +int _ordered_set_ensure_put(OrderedSet **s, const struct hash_ops *ops, void *p HASHMAP_DEBUG_PARAMS); | ||
75 | +#define ordered_set_ensure_put(s, hash_ops, key) _ordered_set_ensure_put(s, hash_ops, key HASHMAP_DEBUG_SRC_ARGS) | ||
76 | |||
77 | static inline OrderedSet* ordered_set_free(OrderedSet *s) { | ||
78 | return (OrderedSet*) ordered_hashmap_free((OrderedHashmap*) s); | ||