]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
memory-util: make ArrayCleanup passed to array_cleanup() const
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 7 May 2023 09:34:35 +0000 (18:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 9 May 2023 08:53:42 +0000 (17:53 +0900)
Should not change any behavior, preparation for later commits.

src/basic/memory-util.h

index d03d52cd438827a023b29d83ed142ff8b701cedb..d26a0918e1adfe0dc2593d1f910ea1da9b8a3443 100644 (file)
@@ -113,13 +113,13 @@ static inline void erase_char(char *p) {
 }
 
 /* An automatic _cleanup_-like logic for destroy arrays (i.e. pointers + size) when leaving scope */
-struct ArrayCleanup {
+typedef struct ArrayCleanup {
         void **parray;
         size_t *pn;
         free_array_func_t pfunc;
-};
+} ArrayCleanup;
 
-static inline void array_cleanup(struct ArrayCleanup *c) {
+static inline void array_cleanup(const ArrayCleanup *c) {
         assert(c);
 
         assert(!c->parray == !c->pn);
@@ -137,7 +137,7 @@ static inline void array_cleanup(struct ArrayCleanup *c) {
 }
 
 #define CLEANUP_ARRAY(array, n, func)                                   \
-        _cleanup_(array_cleanup) _unused_ struct ArrayCleanup CONCATENATE(_cleanup_array_, UNIQ) = { \
+        _cleanup_(array_cleanup) _unused_ const ArrayCleanup CONCATENATE(_cleanup_array_, UNIQ) = { \
                 .parray = (void**) &(array),                            \
                 .pn = &(n),                                             \
                 .pfunc = (free_array_func_t) ({                         \