src/mess/hashfile.c
| r2364 | r2365 | |
| 11 | 11 | #include "expat.h" |
| 12 | 12 | |
| 13 | 13 | |
| 14 | |
| 14 | 15 | /*************************************************************************** |
| 15 | | |
| 16 | | Type definitions |
| 17 | | |
| 16 | TYPE DEFINITIONS |
| 18 | 17 | ***************************************************************************/ |
| 19 | 18 | |
| 20 | 19 | struct _hash_file |
| r2364 | r2365 | |
| 59 | 58 | |
| 60 | 59 | |
| 61 | 60 | /*************************************************************************** |
| 61 | PROTOTYPES |
| 62 | ***************************************************************************/ |
| 62 | 63 | |
| 63 | | Functions |
| 64 | static void *expat_malloc(size_t size); |
| 65 | static void *expat_realloc(void *ptr, size_t size); |
| 66 | static void expat_free(void *ptr); |
| 64 | 67 | |
| 68 | |
| 69 | |
| 70 | /*************************************************************************** |
| 71 | CORE IMPLEMENTATION |
| 65 | 72 | ***************************************************************************/ |
| 66 | 73 | |
| 67 | 74 | static void ATTR_PRINTF(2,3) parse_error(struct hash_parse_state *state, const char *fmt, ...) |
| r2364 | r2365 | |
| 296 | 303 | struct hash_parse_state state; |
| 297 | 304 | char buf[1024]; |
| 298 | 305 | UINT32 len; |
| 306 | XML_Memory_Handling_Suite memcallbacks; |
| 299 | 307 | |
| 300 | 308 | mame_fseek(hashfile->file, 0, SEEK_SET); |
| 301 | 309 | |
| r2364 | r2365 | |
| 306 | 314 | state.error_proc = error_proc; |
| 307 | 315 | state.param = param; |
| 308 | 316 | |
| 309 | | state.parser = XML_ParserCreate(NULL); |
| 317 | /* create the XML parser */ |
| 318 | memcallbacks.malloc_fcn = expat_malloc; |
| 319 | memcallbacks.realloc_fcn = expat_realloc; |
| 320 | memcallbacks.free_fcn = expat_free; |
| 321 | state.parser = XML_ParserCreate_MM(NULL, &memcallbacks, NULL); |
| 310 | 322 | if (!state.parser) |
| 311 | 323 | goto done; |
| 312 | 324 | |
| r2364 | r2365 | |
| 481 | 493 | return 0; |
| 482 | 494 | } |
| 483 | 495 | |
| 496 | |
| 497 | |
| 498 | /*************************************************************************** |
| 499 | EXPAT INTERFACES |
| 500 | ***************************************************************************/ |
| 501 | |
| 502 | /*------------------------------------------------- |
| 503 | expat_malloc/expat_realloc/expat_free - |
| 504 | wrappers for memory allocation functions so |
| 505 | that they pass through out memory tracking |
| 506 | systems |
| 507 | -------------------------------------------------*/ |
| 508 | |
| 509 | static void *expat_malloc(size_t size) |
| 510 | { |
| 511 | return malloc(size); |
| 512 | } |
| 513 | |
| 514 | static void *expat_realloc(void *ptr, size_t size) |
| 515 | { |
| 516 | return realloc(ptr, size); |
| 517 | } |
| 518 | |
| 519 | static void expat_free(void *ptr) |
| 520 | { |
| 521 | free(ptr); |
| 522 | } |