# HG changeset patch # User Michael Pavone # Date 1547781249 28800 # Node ID a0aa9e3c95086ed07e719d39cffa21dba1be3656 # Parent 3f1c8258e20f32128ee0241184e62e37063d9583 Fix SMD ROM support diff -r 3f1c8258e20f -r a0aa9e3c9508 blastem.c --- a/blastem.c Thu Jan 17 19:13:59 2019 -0800 +++ b/blastem.c Thu Jan 17 19:14:09 2019 -0800 @@ -76,14 +76,16 @@ size_t filesize = 512 * 1024; size_t readsize = 0; - uint16_t *dst = malloc(filesize); + uint16_t *dst, *buf; + dst = buf = malloc(filesize); size_t read; do { if ((readsize + SMD_BLOCK_SIZE > filesize)) { filesize *= 2; - dst = realloc(dst, filesize); + buf = realloc(buf, filesize); + dst = buf + readsize/sizeof(uint16_t); } read = romread(block, 1, SMD_BLOCK_SIZE, f); if (read > 0) { @@ -95,7 +97,7 @@ } while(read > 0); romclose(f); - *buffer = dst; + *buffer = buf; return readsize; }