-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
53 lines (43 loc) · 1012 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include "mameMalloc.h"
void test_mame_malloc()
{
uint8_t pool[ 8192 ];
mameMalloc_initialize( (void*)pool, 8192, 3 );
void* p[16];
int slot_index;
for( slot_index = 0; slot_index < 7; slot_index++ )
{
p[ slot_index ] = malloc( 1024 );
assert( p[ slot_index ] );
}
p[ slot_index ] = malloc( 896 );
assert(p[ slot_index ]);
slot_index++;
p[ slot_index ] = malloc( 1 );
assert(p[ slot_index ] == NULL);
slot_index++;
free( p[ 5 ] );
p[ 5 ] = NULL;
while( slot_index < 16 )
{
p[ slot_index ] = malloc( 100 );
assert( p[ slot_index ] );
slot_index++;
}
for( int i = 0; i < 16; i++ )
{
if( p[ i ] )
{
free( p[ i ] );
}
}
mameMalloc_finalize();
}
int main(int argc, const char *argv[])
{
test_mame_malloc();
return 0;
}