Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
malloc.h
Go to the documentation of this file.
1/*
2** Jo Sega Saturn Engine
3** Copyright (c) 2012-2026, Johannes Fetz (johannesfetz@gmail.com)
4** All rights reserved.
5**
6** Redistribution and use in source and binary forms, with or without
7** modification, are permitted provided that the following conditions are met:
8** * Redistributions of source code must retain the above copyright
9** notice, this list of conditions and the following disclaimer.
10** * Redistributions in binary form must reproduce the above copyright
11** notice, this list of conditions and the following disclaimer in the
12** documentation and/or other materials provided with the distribution.
13** * Neither the name of the Johannes Fetz nor the
14** names of its contributors may be used to endorse or promote products
15** derived from this software without specific prior written permission.
16**
17** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
34
35#ifndef __JO_MALLOC_H__
36# define __JO_MALLOC_H__
37
42#define JO_MALLOC_MAX_MEMORY_ZONE (9)
43
54
79
85void *jo_malloc_with_behaviour(unsigned int n, const jo_malloc_behaviour behaviour);
86
91static __jo_force_inline void *jo_malloc(unsigned int n)
92{
94}
95
99void jo_free(const void * const p);
100
105
111void jo_add_memory_zone(unsigned char *ptr, const unsigned int size_in_bytes);
112
113#ifdef JO_COMPILE_WITH_RAM_CARD_SUPPORT
114
118static __jo_force_inline jo_extended_ram_cartridge_type jo_get_extended_ram_cartridge_type(void)
119{
122}
123
124#endif
125
126#ifdef JO_DEBUG
127
133
139
140#endif
141
142#endif /* !__JO_MALLOC_H__ */
143
144/*
145** END OF FILE
146*/
int jo_memory_usage_percent(void)
Get memory usage percent.
void jo_reduce_memory_fragmentation(void)
Reduce memory fragmentation for faster memory allocation.
int jo_memory_fragmentation(void)
Get memory fragmentation (Number of fragment in memory).
static __jo_force_inline void * jo_malloc(unsigned int n)
dynamic memory allocator
Definition malloc.h:91
void jo_free(const void *const p)
function frees the memory space pointed to by p
jo_extended_ram_cartridge_type
Extended RAM cartridge type.
Definition malloc.h:46
@ CART_32MBits
4 Mb cartridge
Definition malloc.h:52
@ CART_8MBits
1 Mb cartridge
Definition malloc.h:50
@ CART_NONE
No cartridge.
Definition malloc.h:48
void * jo_malloc_with_behaviour(unsigned int n, const jo_malloc_behaviour behaviour)
dynamic memory allocator with specific behaviour
jo_malloc_behaviour
Malloc behaviour JO_MALLOC_TRY_REUSE_SAME_BLOCK_SIZE | ^ | | Speed efficiency | | V | JO_MALLOC_TRY_R...
Definition malloc.h:71
@ JO_MALLOC_TRY_REUSE_SAME_BLOCK_SIZE
A little bit slower than JO_MALLOC_TRY_REUSE_BLOCK but reduce memory usage.
Definition malloc.h:77
@ JO_MALLOC_TRY_REUSE_BLOCK
A little bit slower but reduce memory fragmentation.
Definition malloc.h:75
@ JO_FAST_ALLOCATION
Default behaviour.
Definition malloc.h:73
void jo_add_memory_zone(unsigned char *ptr, const unsigned int size_in_bytes)
Register a memory segment for jo_malloc() usage.
#define JO_RAM_CARTRIDGE_ID_32MBITS
Extended RAM cartridge identifier: 4 MB (32 Mbits).
Definition sega_saturn.h:442
#define JO_RAM_CARTRIDGE_ID_8MBITS
Extended RAM cartridge identifier: 1 MB (8 Mbits).
Definition sega_saturn.h:440
#define JO_RAM_CARTRIDGE_ID
Extended RAM cartridge identifier.
Definition sega_saturn.h:438
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition types.h:39