Skip to content

Commit 95609f3

Browse files
committed
basic: Remove circular dep between alloc-util.h and memory-util.h
1 parent 5d226b2 commit 95609f3

File tree

7 files changed

+17
-14
lines changed

7 files changed

+17
-14
lines changed

src/basic/alloc-util.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "alloc-util.h"
88
#include "macro.h"
9-
#include "memory-util.h"
109

1110
void* memdup(const void *p, size_t l) {
1211
void *ret;

src/basic/alloc-util.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "assert-util.h"
1111
#include "macro.h"
12+
#include "memory-util.h"
1213

1314
#if HAS_FEATURE_MEMORY_SANITIZER
1415
# include <sanitizer/msan_interface.h>
@@ -267,5 +268,3 @@ _alloc_(2) static inline void *realloc0(void *p, size_t new_size) {
267268

268269
return q;
269270
}
270-
271-
#include "memory-util.h"

src/basic/keyring-util.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "keyring-util.h"
44
#include "log.h"
5+
#include "alloc-util.h"
56
#include "memory-util.h"
67
#include "missing_syscall.h"
78

src/basic/memory-util.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <threads.h>
44
#include <unistd.h>
55

6+
#include "alloc-util.h"
67
#include "memory-util.h"
78

89
size_t page_size(void) {
@@ -55,3 +56,14 @@ void* memdup_reverse(const void *mem, size_t size) {
5556

5657
return p;
5758
}
59+
60+
void* erase_and_free(void *p) {
61+
size_t l;
62+
63+
if (!p)
64+
return NULL;
65+
66+
l = MALLOC_SIZEOF_SAFE(p);
67+
explicit_bzero_safe(p, l);
68+
return mfree(p);
69+
}

src/basic/memory-util.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <string.h>
88
#include <sys/types.h>
99

10-
#include "alloc-util.h"
1110
#include "macro.h"
1211
#include "memory-util-fundamental.h"
1312

@@ -98,16 +97,7 @@ static inline void* mempmem_safe(const void *haystack, size_t haystacklen, const
9897
return (uint8_t*) p + needlelen;
9998
}
10099

101-
static inline void* erase_and_free(void *p) {
102-
size_t l;
103-
104-
if (!p)
105-
return NULL;
106-
107-
l = MALLOC_SIZEOF_SAFE(p);
108-
explicit_bzero_safe(p, l);
109-
return mfree(p);
110-
}
100+
void* erase_and_free(void *p);
111101

112102
static inline void erase_and_freep(void *p) {
113103
erase_and_free(*(void**) p);

src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-pkcs11.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "sd-json.h"
77

8+
#include "alloc-util.h"
89
#include "cryptsetup-token.h"
910
#include "cryptsetup-token-util.h"
1011
#include "hexdecoct.h"

src/shared/recovery-key.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* SPDX-License-Identifier: LGPL-2.1-or-later */
22

3+
#include "alloc-util.h"
34
#include "memory-util.h"
45
#include "random-util.h"
56
#include "recovery-key.h"

0 commit comments

Comments
 (0)