Jo Engine  9
Jo Sega Saturn Engine
Enumerations | Functions
malloc.h File Reference

Jo Engine Malloc. More...

Go to the source code of this file.

Enumerations

enum  jo_extended_ram_cartridge_type { CART_NONE, CART_8MBits, CART_32MBits }
 Extended RAM cartridge type. More...
 
enum  jo_malloc_behaviour { JO_FAST_ALLOCATION, JO_MALLOC_TRY_REUSE_BLOCK, JO_MALLOC_TRY_REUSE_SAME_BLOCK_SIZE }
 Malloc behaviour JO_MALLOC_TRY_REUSE_SAME_BLOCK_SIZE | ^ | | Speed efficiency | | V | JO_MALLOC_TRY_REUSE_BLOCK | ^ | | Speed efficiency | | V | JO_FAST_ALLOCATION. More...
 

Functions

void * jo_malloc_with_behaviour (unsigned int n, const jo_malloc_behaviour behaviour)
 dynamic memory allocator with specific behaviour More...
 
static __jo_force_inline void * jo_malloc (unsigned int n)
 dynamic memory allocator More...
 
void jo_free (const void *const p)
 function frees the memory space pointed to by ptr, which must have been returned by a previous call to jo_malloc() More...
 
int jo_memory_usage_percent (void)
 Get memory usage percent. More...
 
int jo_memory_fragmentation (void)
 Get memory fragmentation (Number of fragment in memory) More...
 

Detailed Description

Jo Engine Malloc.

Author
Johannes Fetz
Bug:
No known bugs.

Enumeration Type Documentation

Extended RAM cartridge type.

Enumerator
CART_NONE 

No cartridge.

CART_8MBits 

1 Mb cartridge

CART_32MBits 

4 Mb cartridge

Malloc behaviour JO_MALLOC_TRY_REUSE_SAME_BLOCK_SIZE | ^ | | Speed efficiency | | V | JO_MALLOC_TRY_REUSE_BLOCK | ^ | | Speed efficiency | | V | JO_FAST_ALLOCATION.

Enumerator
JO_FAST_ALLOCATION 

Default behaviour.

JO_MALLOC_TRY_REUSE_BLOCK 

A little bit slower but reduce memory fragmentation.

JO_MALLOC_TRY_REUSE_SAME_BLOCK_SIZE 

A little bit slower than JO_MALLOC_TRY_REUSE_BLOCK but reduce memory usage.

Function Documentation

void jo_free ( const void *const  p)

function frees the memory space pointed to by ptr, which must have been returned by a previous call to jo_malloc()

static __jo_force_inline void* jo_malloc ( unsigned int  n)
static

dynamic memory allocator

Parameters
nSegment size
Returns
a pointer to the allocated memory or NULL if failed
void* jo_malloc_with_behaviour ( unsigned int  n,
const jo_malloc_behaviour  behaviour 
)

dynamic memory allocator with specific behaviour

Parameters
nSegment size
behaviourAllocation Behaviour
Returns
a pointer to the allocated memory or NULL if failed
int jo_memory_fragmentation ( void  )

Get memory fragmentation (Number of fragment in memory)

Returns
Memory fragmentation
Remarks
jo_printf(0, 0, "Dynamic memory fragmentation: %d%% ", jo_memory_fragmentation());
int jo_memory_usage_percent ( void  )

Get memory usage percent.

Returns
memory usage percent
Remarks
jo_printf(0, 0, "Dynamic memory usage: %d%% ", jo_memory_usage_percent());