(ref) Removed malloc

This commit is contained in:
Devine Lu Linvega 2024-01-10 12:51:38 -08:00
parent 6e92c7aaae
commit 12c3a8eecd
2 changed files with 2 additions and 13 deletions

BIN
ref/uxn

Binary file not shown.

View File

@ -17,7 +17,7 @@ typedef struct {
} Stack; } Stack;
typedef struct Uxn { typedef struct Uxn {
Uint8 *ram, dev[0x100]; Uint8 ram[0x10000], dev[0x100];
Stack wst, rst; Stack wst, rst;
} Uxn; } Uxn;
@ -33,16 +33,6 @@ system_load(Uxn *u, char *filename)
return 1; return 1;
} }
int
system_init(Uxn *u, Uint8 *ram, char *rom)
{
u->ram = ram;
if(!system_load(u, rom))
if(!system_load(u, "boot.rom"))
return 0;
return 1;
}
int int
console_input(Uxn *u, char c, int type) console_input(Uxn *u, char c, int type)
{ {
@ -175,7 +165,7 @@ main(int argc, char **argv)
fprintf(stdout, "usage: %s file.rom [args..]\n", argv[0]); fprintf(stdout, "usage: %s file.rom [args..]\n", argv[0]);
return 0; return 0;
} }
if(!system_init(&u, (Uint8 *)calloc(0x10000, sizeof(Uint8)), argv[i++])) { if(!system_load(&u, argv[i++])) {
fprintf(stderr, "Failed to initialize %s\n", argv[1]); fprintf(stderr, "Failed to initialize %s\n", argv[1]);
return 0; return 0;
} }
@ -192,6 +182,5 @@ main(int argc, char **argv)
console_input(&u, (Uint8)c, 0x1); console_input(&u, (Uint8)c, 0x1);
} }
} }
free(u.ram);
return u.dev[0x0f] & 0x7f; return u.dev[0x0f] & 0x7f;
} }