Jo Engine  9
Jo Sega Saturn Engine
malloc.h
Go to the documentation of this file.
1 /*
2 ** Jo Sega Saturn Engine
3 ** Copyright (c) 2012-2017, 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 */
35 #ifndef __JO_MALLOC_H__
36 # define __JO_MALLOC_H__
37 
39 typedef enum
40 {
48 
64 typedef enum
65 {
73 
79 void *jo_malloc_with_behaviour(unsigned int n, const jo_malloc_behaviour behaviour);
80 
85 static __jo_force_inline void *jo_malloc(unsigned int n)
86 {
88 }
89 
92 void jo_free(const void * const p);
93 
94 #ifdef JO_COMPILE_WITH_RAM_CARD_SUPPORT
95 
99 static __jo_force_inline jo_extended_ram_cartridge_type jo_get_extended_ram_cartridge_type(void)
100 {
101  return *((char *)0x24FFFFFF) == 0x5a ? CART_8MBits : *((char *)0x24FFFFFF) == 0x5c ? CART_32MBits : CART_NONE;
102 }
103 
104 #endif
105 
106 #ifdef JO_DEBUG
107 
112 int jo_memory_usage_percent(void);
113 
118 int jo_memory_fragmentation(void);
119 
120 #endif
121 
122 #endif /* !__JO_MALLOC_H__ */
123 
124 /*
125 ** END OF FILE
126 */
A little bit slower than JO_MALLOC_TRY_REUSE_BLOCK but reduce memory usage.
Definition: malloc.h:71
1 Mb cartridge
Definition: malloc.h:44
jo_extended_ram_cartridge_type
Extended RAM cartridge type.
Definition: malloc.h:39
int jo_memory_fragmentation(void)
Get memory fragmentation (Number of fragment in memory)
4 Mb cartridge
Definition: malloc.h:46
Default behaviour.
Definition: malloc.h:67
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition: conf.h:154
int jo_memory_usage_percent(void)
Get memory usage percent.
void * jo_malloc_with_behaviour(unsigned int n, const jo_malloc_behaviour behaviour)
dynamic memory allocator with specific behaviour
No cartridge.
Definition: malloc.h:42
jo_malloc_behaviour
Malloc behaviour JO_MALLOC_TRY_REUSE_SAME_BLOCK_SIZE | ^ | | Speed efficiency | | V | JO_MALLOC_TRY_R...
Definition: malloc.h:64
A little bit slower but reduce memory fragmentation.
Definition: malloc.h:69
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 t...
static __jo_force_inline void * jo_malloc(unsigned int n)
dynamic memory allocator
Definition: malloc.h:85