Turnstone Operating System
Loading...
Searching...
No Matches
memory.h File Reference

memory functions More...

#include <types.h>

Classes

struct  memory_heap_stat_t
 heap statistics, both monitoring and leak analysis. More...
 
struct  memory_heap_t
 heap interface for all types More...
 

Macros

#define ___MEMORY_H   0
 
#define memory_get_heap_stat(s)
 
#define memory_free(addr)
 
#define memory_malloc(s)
 
#define memory_malloc_aligned(s, a)
 

Typedefs

typedef struct memory_heap_stat_t memory_heap_stat_t
 short hand for struct
 
typedef struct memory_heap_t memory_heap_t
 short hand for struct
 

Functions

memory_heap_tmemory_create_heap_simple (size_t start, size_t end)
 creates simple heap
 
memory_heap_tmemory_create_heap_hash (size_t start, size_t end)
 creates hash backended heap
 
memory_heap_tmemory_set_default_heap (memory_heap_t *heap)
 sets default heap
 
memory_heap_tmemory_get_default_heap (void)
 returns default heap
 
memory_heap_tmemory_get_heap (memory_heap_t *heap)
 returns heap, finds correct heap for task.
 
void memory_get_heap_stat_ext (memory_heap_t *heap, memory_heap_stat_t *stat)
 returns stats for heap
 
int8_t memory_free_ext (memory_heap_t *heap, void *address)
 frees memory
 
void * memory_malloc_ext (memory_heap_t *heap, size_t size, size_t align)
 malloc memory
 
int8_t memory_memset (void *address, uint8_t value, size_t size)
 sets memory with value
 
int8_t memory_memclean (void *address, size_t size)
 zeros memory
 
int8_t memory_memcopy (const void *source, void *destination, size_t size)
 copy source to destination with length bytes from source
 
int8_t memory_memcompare (const void *mem1, const void *mem2, size_t size)
 compares first length bytes of mem1 with mem2
 

Detailed Description

memory functions

This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.

Macro Definition Documentation

◆ ___MEMORY_H

#define ___MEMORY_H   0

prevent duplicate header error macro

◆ memory_free

#define memory_free ( addr)
Value:
memory_free_ext(NULL, addr)
int8_t memory_free_ext(memory_heap_t *heap, void *address)
frees memory
Definition memory.xx.c:105

frees memory addr at default heap

◆ memory_get_heap_stat

#define memory_get_heap_stat ( s)
Value:
void memory_get_heap_stat_ext(memory_heap_t *heap, memory_heap_stat_t *stat)
returns stats for heap
Definition memory.xx.c:132

returns stats for default heap

◆ memory_malloc

#define memory_malloc ( s)
Value:
memory_malloc_ext(NULL, s, 0x0)
void * memory_malloc_ext(memory_heap_t *heap, size_t size, size_t align)
malloc memory
Definition memory.xx.c:60

malloc with size s at default heap without aligned

◆ memory_malloc_aligned

#define memory_malloc_aligned ( s,
a )
Value:
memory_malloc_ext(NULL, s, a)

malloc with size s at default heap with aligned a

Function Documentation

◆ memory_create_heap_hash()

memory_heap_t * memory_create_heap_hash ( size_t start,
size_t end )

creates hash backended heap

Parameters
[in]startstart address of heap
[in]endend address of heap
Returns
heap

◆ memory_create_heap_simple()

memory_heap_t * memory_create_heap_simple ( size_t start,
size_t end )

creates simple heap

Parameters
[in]startstart address of heap
[in]endend address of heap
Returns
heap

◆ memory_free_ext()

int8_t memory_free_ext ( memory_heap_t * heap,
void * address )

frees memory

Parameters
[in]heapthe heap where the address is.
[in]addressaddress to free
Returns
0 if successed.

if heap is NULL, address will be freed at default heap

◆ memory_get_default_heap()

memory_heap_t * memory_get_default_heap ( void )

returns default heap

Returns
default heap

◆ memory_get_heap()

memory_heap_t * memory_get_heap ( memory_heap_t * heap)

returns heap, finds correct heap for task.

Returns
correct heap for task

◆ memory_get_heap_stat_ext()

void memory_get_heap_stat_ext ( memory_heap_t * heap,
memory_heap_stat_t * stat )

returns stats for heap

Parameters
[in]heapheap which stats will be collected
[out]statreturned stats

◆ memory_malloc_ext()

void * memory_malloc_ext ( memory_heap_t * heap,
size_t size,
size_t align )

malloc memory

Parameters
[in]heapthe heap used for malloc
[in]sizesize of variable
[in]alignaddress of variable aligned at.
Returns
address of variable

if heap is NULL, variable allocated at default heap.

◆ memory_memclean()

int8_t memory_memclean ( void * address,
size_t size )

zeros memory

Parameters
[in]athe address to be zerod.
[in]srepeat count
Returns
0

◆ memory_memcompare()

int8_t memory_memcompare ( const void * mem1,
const void * mem2,
size_t size )

compares first length bytes of mem1 with mem2

Parameters
mem1first memory address
mem2second memory address
sizecount of bytes for compare
Returns
<0 if mem1>mem2, 0 if mem1=mem2, >0 if mem1>mem2

◆ memory_memcopy()

int8_t memory_memcopy ( const void * source,
void * destination,
size_t size )

copy source to destination with length bytes from source

Parameters
[in]sourcesource address
[in]destinationdestination address
[in]sizehow many bytes will be copied
Returns
0

if destination is smaller then length a memory corruption will be happend

◆ memory_memset()

int8_t memory_memset ( void * address,
uint8_t value,
size_t size )

sets memory with value

Parameters
[in]addressthe address to be setted.
[in]valuethe value
[in]sizerepeat count
Returns
0

◆ memory_set_default_heap()

memory_heap_t * memory_set_default_heap ( memory_heap_t * heap)

sets default heap

Parameters
[in]heapthe heap will be the default one
Returns
old default heap