Mercurial > repos > blastem
comparison serialize.c @ 1428:2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 09 Aug 2017 23:26:51 -0700 |
parents | 4e5797b3935a |
children | c3c62dbf1ceb |
comparison
equal
deleted
inserted
replaced
1427:4e5797b3935a | 1428:2540c05520f2 |
---|---|
255 } | 255 } |
256 if (fread(ident, 1, sizeof(ident), f) != sizeof(ident)) { | 256 if (fread(ident, 1, sizeof(ident), f) != sizeof(ident)) { |
257 fclose(f); | 257 fclose(f); |
258 return 0; | 258 return 0; |
259 } | 259 } |
260 fclose(f); | |
261 if (memcmp(ident, sz_ident, sizeof(ident))) { | 260 if (memcmp(ident, sz_ident, sizeof(ident))) { |
262 return 0; | 261 return 0; |
263 } | 262 } |
264 buf->size = size - sizeof(ident); | 263 buf->size = size - sizeof(ident); |
265 buf->cur_pos = 0; | 264 buf->cur_pos = 0; |
266 buf->data = malloc(buf->size); | 265 buf->data = malloc(buf->size); |
267 buf->handlers = NULL; | 266 buf->handlers = NULL; |
268 buf->max_handler = 8; | 267 buf->max_handler = 8; |
269 if (fread(buf->data, 1, buf->size, f) != buf->size) { | 268 if (fread(buf->data, 1, buf->size, f) != buf->size) { |
269 fclose(f); | |
270 free(buf->data); | 270 free(buf->data); |
271 buf->data = NULL; | 271 buf->data = NULL; |
272 buf->size = 0; | 272 buf->size = 0; |
273 return 0; | 273 return 0; |
274 } | 274 } |
275 fclose(f); | |
275 return 1; | 276 return 1; |
276 } | 277 } |