mm (Memory Management)ο
Header: udo/mm.h
Table of contents (click to go)ο
Macrosο
Enumsο
Unionsο
Structsο
Functionsο
API Documentationο
This interface was built to force caller
to be more consciously concern about heap
based virtual memory management.
udo_mm (private)ο
-
struct udo_mmο
-
struct udo_log_error_struct err;ο
-
size_t buff_sz;ο
-
size_t data_sz;ο
-
size_t ab_sz;ο
-
size_t offset;ο
err- Stores information about the error that occuredfor the given context and may later be retrieved.by caller.
buff_sz- Full size of the
structudo_mmcontext.Not all bytes in the buffer are writable. data_sz- Full size of the caller writable data.
ab_sz- The amount of available bytes the callercan still write to.
offset- Buffer offset used when allocating new blocksin constant time. Caller may not of used theentire buffer before re-allocation. Member isused to keep track of end of buffer where dataexist.
-
struct udo_log_error_struct err;ο
udo_mm_allocο
Returns pointer to an allocated block of heap
memory. The goal of this is to allocate a large
block of memory once. If re-allocation required
pass the previous large block to clone all data.
Addresses returned from function should not
be used to write to. Writable addresses
are return from a call to
udo_mm_sub_alloc().
Param
Decription
mm
IfNULLthe inital allocation will be performed.size
Size of data caller may allocate. If thesize is greater than the larger blockremapping of memory will occur.
- Returns:
on success: Pointer to astructudo_mmon failure:NULL
udo_mm_sub_allocο
Returns pointer to an allocated block of heap
memory. From the allocated larger block of
memory sub-allocate from that larger block.
Addresses returned from function can be
used for writing.
Param
Decription
mm
Must pass a pointer to astructudo_mm.size
Size of buffer to sub-allocate.
- Returns:
on success: Pointer to writable memoryon failure:NULL
udo_mm_sub_alloc_get_sizeο
-
void *udo_mm_sub_alloc_get_size(const void *data);ο
Returns size of an allocated heap
memory sub block.
Param
Decription
data
Must pass address returned aftercall toudo_mm_sub_alloc().
- Returns:
on success: Size of allocated sub blockon failure: (size_t)-1
udo_mm_freeο
Wipes the bytes at a given subregion of memory.
Shifts the memory after the subregion over to
the start of the wiped subregion.
NOTE: This function should be used sparingly
as the caller would have to keep track of the
new pointer address for every object allocated.
Itβs better to only allocate memory if you know
the address it resides in wonβt change. Usages
of bounded buffer for strings is encouraged.
Param
Decription
mm
Must pass a pointer to astructudo_mm.data
Address to the data caller wants to zero out.
udo_mm_destroyο
Freeβs the large block of allocated memory created after
udo_mm_alloc() call.
Param
Decription
flops
Must pass a pointer to astructudo_mm.