Fix mallocing issue with ram array

Thu, 02 Dec 2010 17:12:28 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Thu, 02 Dec 2010 17:12:28 +0000
changeset 33
ae97a3146978
parent 32
a44afcf2354c
child 34
e8ebd433270a

Fix mallocing issue with ram array

RAM storage array was not being correctly allocated at startup. This caused memory access issues... Spotted with Valgrind, fixed.

src/state.c file | annotate | diff | revisions
     1.1 --- a/src/state.c	Thu Dec 02 17:01:34 2010 +0000
     1.2 +++ b/src/state.c	Thu Dec 02 17:12:28 2010 +0000
     1.3 @@ -17,7 +17,7 @@
     1.4  	// Basically: 512KiB minimum, 4MiB maximum, in increments of 512KiB.
     1.5  	if ((ramsize < 512*1024) || ((ramsize % (512*1024)) != 0))
     1.6  		return -1;
     1.7 -	state.ram = malloc(state.ram_size);
     1.8 +	state.ram = malloc(ramsize);
     1.9  	if (state.ram == NULL)
    1.10  		return -2;
    1.11  	state.ram_size = ramsize;