summaryrefslogtreecommitdiffstats
path: root/src/interface/linux/linux_umalloc.c
diff options
context:
space:
mode:
authorMichael Brown2025-04-23 13:47:53 +0200
committerMichael Brown2025-04-23 15:43:04 +0200
commit839540cb95a310ebf96d6302afecc3ac97ccf746 (patch)
tree67c13ca2d9a48e3d63b5e739492646ee69c9e6cb /src/interface/linux/linux_umalloc.c
parent[smbios] Remove userptr_t from SMBIOS structure parsing (diff)
downloadipxe-839540cb95a310ebf96d6302afecc3ac97ccf746.tar.gz
ipxe-839540cb95a310ebf96d6302afecc3ac97ccf746.tar.xz
ipxe-839540cb95a310ebf96d6302afecc3ac97ccf746.zip
[umalloc] Remove userptr_t from user memory allocations
Use standard void pointers for umalloc(), urealloc(), and ufree(), with the "u" prefix retained to indicate that these allocations are made from external ("user") memory rather than from the internal heap. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/linux/linux_umalloc.c')
-rw-r--r--src/interface/linux/linux_umalloc.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/interface/linux/linux_umalloc.c b/src/interface/linux/linux_umalloc.c
index a7250fa5b..ab5770e9c 100644
--- a/src/interface/linux/linux_umalloc.c
+++ b/src/interface/linux/linux_umalloc.c
@@ -31,9 +31,6 @@ FILE_LICENCE(GPL2_OR_LATER);
#include <ipxe/linux_api.h>
-/** Special address returned for empty allocations */
-#define NOWHERE ((void *)-1)
-
/** Poison to make the metadata more unique */
#define POISON 0xa5a5a5a5
#define min(a,b) (((a)<(b))?(a):(b))
@@ -47,7 +44,16 @@ struct metadata
#define SIZE_MD (sizeof(struct metadata))
-/** Simple realloc which passes most of the work to mmap(), mremap() and munmap() */
+/**
+ * Reallocate external memory
+ *
+ * @v old_ptr Memory previously allocated by umalloc(), or NULL
+ * @v new_size Requested size
+ * @ret new_ptr Allocated memory, or NULL
+ *
+ * Calling realloc() with a new size of zero is a valid way to free a
+ * memory block.
+ */
static void * linux_realloc(void *ptr, size_t size)
{
struct metadata md = {0, 0};
@@ -136,19 +142,4 @@ static void * linux_realloc(void *ptr, size_t size)
return ptr;
}
-/**
- * Reallocate external memory
- *
- * @v old_ptr Memory previously allocated by umalloc(), or UNULL
- * @v new_size Requested size
- * @ret new_ptr Allocated memory, or UNULL
- *
- * Calling realloc() with a new size of zero is a valid way to free a
- * memory block.
- */
-static userptr_t linux_urealloc(userptr_t old_ptr, size_t new_size)
-{
- return (userptr_t)linux_realloc((void *)old_ptr, new_size);
-}
-
-PROVIDE_UMALLOC(linux, urealloc, linux_urealloc);
+PROVIDE_UMALLOC(linux, urealloc, linux_realloc);