iPXE
umalloc_test.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <ipxe/uaccess.h>
3 #include <ipxe/umalloc.h>
4 #include <ipxe/io.h>
5 
6 void umalloc_test ( void ) {
7  struct memory_map memmap;
8  userptr_t bob;
9  userptr_t fred;
10 
11  printf ( "Before allocation:\n" );
12  get_memmap ( &memmap );
13 
14  bob = umalloc ( 1234 );
15  bob = urealloc ( bob, 12345 );
16  fred = umalloc ( 999 );
17 
18  printf ( "After allocation:\n" );
19  get_memmap ( &memmap );
20 
21  ufree ( bob );
22  ufree ( fred );
23 
24  printf ( "After freeing:\n" );
25  get_memmap ( &memmap );
26 }
iPXE I/O API
void get_memmap(struct memory_map *memmap)
Get memory map.
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
A memory map.
Definition: io.h:499
Access to external ("user") memory.
void umalloc_test(void)
Definition: umalloc_test.c:6
userptr_t urealloc(userptr_t userptr, size_t new_size)
Reallocate external memory.
User memory allocation.
static __always_inline void ufree(userptr_t userptr)
Free external memory.
Definition: umalloc.h:65
static __always_inline userptr_t umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:54
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33