File: memtest.c

package info (click to toggle)
libemu 0.2.0%2Bgit20120122-1.2
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 3,360 kB
  • ctags: 1,872
  • sloc: ansic: 43,547; makefile: 211; python: 14
file content (39 lines) | stat: -rw-r--r-- 570 bytes parent folder | download
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
#include <stdio.h>
#include "emu/emu.h"
#include "emu/emu_memory.h"

void test_alloc(struct emu *e)
{
	const uint32_t len = 4711;
	uint32_t addr;
	struct emu_memory *m = emu_memory_get(e);
	
	emu_memory_alloc(m, &addr, len);
	
	printf("allocd at 0x%08x\n", addr);
	
	int i;
	
	for( i = 0; i < len; i++ )
	{
		uint8_t byte;
		if( emu_memory_read_byte(m, addr + i, &byte) )
		{
			printf("error reading allocated byte: %s\n", emu_strerror(e));
		}
	}
}


int main(int argc, char **argv)
{
	struct emu *e;
	
	e = emu_new();
	
	test_alloc(e);
	
	emu_free(e);
	
	return 0;
}