basic: Remove circular dep between alloc-util.h and memory-util.h

This commit is contained in:
Daan De Meyer
2025-04-12 16:59:43 +02:00
parent 5d226b2f9a
commit 95609f3dff
7 changed files with 17 additions and 14 deletions

View File

@@ -6,7 +6,6 @@
#include "alloc-util.h"
#include "macro.h"
#include "memory-util.h"
void* memdup(const void *p, size_t l) {
void *ret;

View File

@@ -9,6 +9,7 @@
#include "assert-util.h"
#include "macro.h"
#include "memory-util.h"
#if HAS_FEATURE_MEMORY_SANITIZER
# include <sanitizer/msan_interface.h>
@@ -267,5 +268,3 @@ _alloc_(2) static inline void *realloc0(void *p, size_t new_size) {
return q;
}
#include "memory-util.h"

View File

@@ -2,6 +2,7 @@
#include "keyring-util.h"
#include "log.h"
#include "alloc-util.h"
#include "memory-util.h"
#include "missing_syscall.h"

View File

@@ -3,6 +3,7 @@
#include <threads.h>
#include <unistd.h>
#include "alloc-util.h"
#include "memory-util.h"
size_t page_size(void) {
@@ -55,3 +56,14 @@ void* memdup_reverse(const void *mem, size_t size) {
return p;
}
void* erase_and_free(void *p) {
size_t l;
if (!p)
return NULL;
l = MALLOC_SIZEOF_SAFE(p);
explicit_bzero_safe(p, l);
return mfree(p);
}

View File

@@ -7,7 +7,6 @@
#include <string.h>
#include <sys/types.h>
#include "alloc-util.h"
#include "macro.h"
#include "memory-util-fundamental.h"
@@ -98,16 +97,7 @@ static inline void* mempmem_safe(const void *haystack, size_t haystacklen, const
return (uint8_t*) p + needlelen;
}
static inline void* erase_and_free(void *p) {
size_t l;
if (!p)
return NULL;
l = MALLOC_SIZEOF_SAFE(p);
explicit_bzero_safe(p, l);
return mfree(p);
}
void* erase_and_free(void *p);
static inline void erase_and_freep(void *p) {
erase_and_free(*(void**) p);

View File

@@ -5,6 +5,7 @@
#include "sd-json.h"
#include "alloc-util.h"
#include "cryptsetup-token.h"
#include "cryptsetup-token-util.h"
#include "hexdecoct.h"

View File

@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "memory-util.h"
#include "random-util.h"
#include "recovery-key.h"