diff options
author | 2025-03-12 17:23:33 +1100 | |
---|---|---|
committer | 2025-03-12 17:23:33 +1100 | |
commit | 288839a39514c5fa8d105655fa7c11bd6ca0de03 (patch) | |
tree | 63cddc1c8579091287a2821c24e2f0ab8ef3c874 /3rdparty/expat/tests/memcheck.c | |
parent | d69383bfb699daace0b565aa0ecdecdf39a119d1 (diff) |
3rdparty/expat: Updated to expat 2.6.4.
Diffstat (limited to '3rdparty/expat/tests/memcheck.c')
-rw-r--r-- | 3rdparty/expat/tests/memcheck.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/3rdparty/expat/tests/memcheck.c b/3rdparty/expat/tests/memcheck.c index 41355f6c8d9..de925499721 100644 --- a/3rdparty/expat/tests/memcheck.c +++ b/3rdparty/expat/tests/memcheck.c @@ -6,8 +6,9 @@ \___/_/\_\ .__/ \__,_|\__| |_| XML parser - Copyright (c) 1997-2000 Thai Open Source Software Center Ltd - Copyright (c) 2000-2017 Expat development team + Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> + Copyright (c) 2017-2023 Sebastian Pipping <sebastian@pipping.org> + Copyright (c) 2022 Sean McBride <sean@rogue-research.com> Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -49,12 +50,13 @@ typedef struct allocation_entry { static AllocationEntry *alloc_head = NULL; static AllocationEntry *alloc_tail = NULL; -static AllocationEntry *find_allocation(void *ptr); +static AllocationEntry *find_allocation(const void *ptr); /* Allocate some memory and keep track of it. */ void * tracking_malloc(size_t size) { - AllocationEntry *entry = malloc(sizeof(AllocationEntry)); + AllocationEntry *const entry + = (AllocationEntry *)malloc(sizeof(AllocationEntry)); if (entry == NULL) { printf("Allocator failure\n"); @@ -82,7 +84,7 @@ tracking_malloc(size_t size) { } static AllocationEntry * -find_allocation(void *ptr) { +find_allocation(const void *ptr) { AllocationEntry *entry; for (entry = alloc_head; entry != NULL; entry = entry->next) { @@ -140,7 +142,7 @@ tracking_realloc(void *ptr, size_t size) { entry = find_allocation(ptr); if (entry == NULL) { printf("Attempting to realloc unallocated memory at %p\n", ptr); - entry = malloc(sizeof(AllocationEntry)); + entry = (AllocationEntry *)malloc(sizeof(AllocationEntry)); if (entry == NULL) { printf("Reallocator failure\n"); return NULL; @@ -162,12 +164,11 @@ tracking_realloc(void *ptr, size_t size) { alloc_tail = entry; } } else { - entry->allocation = realloc(ptr, size); - if (entry->allocation == NULL) { - /* Realloc semantics say the original is still allocated */ - entry->allocation = ptr; + void *const reallocated = realloc(ptr, size); + if (reallocated == NULL) { return NULL; } + entry->allocation = reallocated; } entry->num_bytes = size; |