2021-12-19 19:45:39 +01:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
Copyright (c) 2018-2020, Microsoft Research, Daan Leijen
|
|
|
|
This is free software; you can redistribute it and/or modify it under the
|
|
|
|
terms of the MIT license. A copy of the license can be found in the file
|
|
|
|
"LICENSE" at the root of this distribution.
|
|
|
|
-----------------------------------------------------------------------------*/
|
|
|
|
#include "mimalloc.h"
|
|
|
|
#include "mimalloc-types.h"
|
|
|
|
|
|
|
|
#include "testhelper.h"
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Helper functions
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
bool check_zero_init(uint8_t* p, size_t size);
|
2021-12-19 21:56:52 +01:00
|
|
|
#if MI_DEBUG >= 2
|
|
|
|
bool check_debug_fill_uninit(uint8_t* p, size_t size);
|
2021-12-19 21:57:06 +01:00
|
|
|
bool check_debug_fill_freed(uint8_t* p, size_t size);
|
2021-12-19 21:56:52 +01:00
|
|
|
#endif
|
2021-12-19 19:45:39 +01:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Main testing
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
int main(void) {
|
|
|
|
mi_option_disable(mi_option_verbose);
|
|
|
|
|
|
|
|
// ---------------------------------------------------
|
|
|
|
// Zeroing allocation
|
|
|
|
// ---------------------------------------------------
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("zeroinit-zalloc-small") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_zalloc(zalloc_size);
|
|
|
|
result = check_zero_init(p, zalloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("zeroinit-zalloc-large") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t zalloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_zalloc(zalloc_size);
|
|
|
|
result = check_zero_init(p, zalloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("zeroinit-zalloc_small") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_zalloc_small(zalloc_size);
|
|
|
|
result = check_zero_init(p, zalloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 19:45:39 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("zeroinit-calloc-small") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t calloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_calloc(calloc_size, 1);
|
|
|
|
result = check_zero_init(p, calloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("zeroinit-calloc-large") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t calloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_calloc(calloc_size, 1);
|
|
|
|
result = check_zero_init(p, calloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 19:45:39 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("zeroinit-rezalloc-small") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_zalloc(zalloc_size);
|
|
|
|
result = check_zero_init(p, zalloc_size);
|
|
|
|
zalloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_rezalloc(p, zalloc_size);
|
|
|
|
result &= check_zero_init(p, zalloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("zeroinit-rezalloc-large") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t zalloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_zalloc(zalloc_size);
|
|
|
|
result = check_zero_init(p, zalloc_size);
|
|
|
|
zalloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_rezalloc(p, zalloc_size);
|
|
|
|
result &= check_zero_init(p, zalloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 19:45:39 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("zeroinit-recalloc-small") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t calloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_calloc(calloc_size, 1);
|
|
|
|
result = check_zero_init(p, calloc_size);
|
|
|
|
calloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_recalloc(p, calloc_size, 1);
|
|
|
|
result &= check_zero_init(p, calloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("zeroinit-recalloc-large") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t calloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_calloc(calloc_size, 1);
|
|
|
|
result = check_zero_init(p, calloc_size);
|
|
|
|
calloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_recalloc(p, calloc_size, 1);
|
|
|
|
result &= check_zero_init(p, calloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 19:45:39 +01:00
|
|
|
|
|
|
|
// ---------------------------------------------------
|
|
|
|
// Zeroing in aligned API
|
|
|
|
// ---------------------------------------------------
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("zeroinit-zalloc_aligned-small") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_zalloc_aligned(zalloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_zero_init(p, zalloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("zeroinit-zalloc_aligned-large") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t zalloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_zalloc_aligned(zalloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_zero_init(p, zalloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 19:45:39 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("zeroinit-calloc_aligned-small") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t calloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_calloc_aligned(calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_zero_init(p, calloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("zeroinit-calloc_aligned-large") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t calloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_calloc_aligned(calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_zero_init(p, calloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 19:45:39 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("zeroinit-rezalloc_aligned-small") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_zalloc_aligned(zalloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_zero_init(p, zalloc_size);
|
|
|
|
zalloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_rezalloc_aligned(p, zalloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result &= check_zero_init(p, zalloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("zeroinit-rezalloc_aligned-large") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t zalloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_zalloc_aligned(zalloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_zero_init(p, zalloc_size);
|
|
|
|
zalloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_rezalloc_aligned(p, zalloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result &= check_zero_init(p, zalloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 19:45:39 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("zeroinit-recalloc_aligned-small") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t calloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_calloc_aligned(calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_zero_init(p, calloc_size);
|
|
|
|
calloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_recalloc_aligned(p, calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result &= check_zero_init(p, calloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("zeroinit-recalloc_aligned-large") {
|
2021-12-19 19:45:39 +01:00
|
|
|
size_t calloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_calloc_aligned(calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_zero_init(p, calloc_size);
|
|
|
|
calloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_recalloc_aligned(p, calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result &= check_zero_init(p, calloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 19:45:39 +01:00
|
|
|
|
2021-12-19 21:56:52 +01:00
|
|
|
#if MI_DEBUG >= 2
|
|
|
|
// ---------------------------------------------------
|
|
|
|
// Debug filling
|
|
|
|
// ---------------------------------------------------
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("uninit-malloc-small") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("uninit-malloc-large") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 21:56:52 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("uninit-malloc_small") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc_small(malloc_size);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 21:56:52 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("uninit-realloc-small") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
malloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_realloc(p, malloc_size);
|
|
|
|
result &= check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("uninit-realloc-large") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
malloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_realloc(p, malloc_size);
|
|
|
|
result &= check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 21:56:52 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("uninit-mallocn-small") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_mallocn(malloc_size, 1);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("uninit-mallocn-large") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_mallocn(malloc_size, 1);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 21:56:52 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("uninit-reallocn-small") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_mallocn(malloc_size, 1);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
malloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_reallocn(p, malloc_size, 1);
|
|
|
|
result &= check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("uninit-reallocn-large") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_mallocn(malloc_size, 1);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
malloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_reallocn(p, malloc_size, 1);
|
|
|
|
result &= check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 21:56:52 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("uninit-malloc_aligned-small") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc_aligned(malloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("uninit-malloc_aligned-large") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc_aligned(malloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 21:56:52 +01:00
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("uninit-realloc_aligned-small") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc_aligned(malloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
malloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_realloc_aligned(p, malloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result &= check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("uninit-realloc_aligned-large") {
|
2021-12-19 21:56:52 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc_aligned(malloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result = check_debug_fill_uninit(p, malloc_size);
|
|
|
|
malloc_size *= 3;
|
|
|
|
p = (uint8_t*)mi_realloc_aligned(p, malloc_size, MI_MAX_ALIGN_SIZE * 2);
|
|
|
|
result &= check_debug_fill_uninit(p, malloc_size);
|
|
|
|
mi_free(p);
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 21:57:06 +01:00
|
|
|
|
|
|
|
|
2022-04-19 10:49:39 -07:00
|
|
|
CHECK_BODY("fill-freed-small") {
|
2021-12-19 21:57:06 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
|
|
|
|
mi_free(p);
|
|
|
|
// First sizeof(void*) bytes will contain housekeeping data, skip these
|
|
|
|
result = check_debug_fill_freed(p + sizeof(void*), malloc_size - sizeof(void*));
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
|
|
|
CHECK_BODY("fill-freed-large") {
|
2021-12-19 21:57:06 +01:00
|
|
|
size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
|
|
|
|
uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
|
|
|
|
mi_free(p);
|
|
|
|
// First sizeof(void*) bytes will contain housekeeping data, skip these
|
|
|
|
result = check_debug_fill_freed(p + sizeof(void*), malloc_size - sizeof(void*));
|
2022-04-19 10:49:39 -07:00
|
|
|
};
|
2021-12-19 21:56:52 +01:00
|
|
|
#endif
|
|
|
|
|
2021-12-19 19:45:39 +01:00
|
|
|
// ---------------------------------------------------
|
|
|
|
// Done
|
|
|
|
// ---------------------------------------------------[]
|
|
|
|
return print_test_summary();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Helper functions
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
bool check_zero_init(uint8_t* p, size_t size) {
|
|
|
|
if(!p)
|
|
|
|
return false;
|
|
|
|
bool result = true;
|
|
|
|
for (size_t i = 0; i < size; ++i) {
|
|
|
|
result &= p[i] == 0;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2021-12-19 21:56:52 +01:00
|
|
|
|
|
|
|
#if MI_DEBUG >= 2
|
|
|
|
bool check_debug_fill_uninit(uint8_t* p, size_t size) {
|
2023-03-06 09:02:38 -08:00
|
|
|
#if MI_TRACK_VALGRIND
|
2022-10-30 14:07:41 -07:00
|
|
|
(void)p; (void)size;
|
|
|
|
return true; // when compiled with valgrind we don't init on purpose
|
|
|
|
#else
|
2021-12-19 21:56:52 +01:00
|
|
|
if(!p)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool result = true;
|
|
|
|
for (size_t i = 0; i < size; ++i) {
|
|
|
|
result &= p[i] == MI_DEBUG_UNINIT;
|
|
|
|
}
|
|
|
|
return result;
|
2022-10-30 14:07:41 -07:00
|
|
|
#endif
|
2021-12-19 21:56:52 +01:00
|
|
|
}
|
2021-12-19 21:57:06 +01:00
|
|
|
|
|
|
|
bool check_debug_fill_freed(uint8_t* p, size_t size) {
|
2023-03-06 09:02:38 -08:00
|
|
|
#if MI_TRACK_VALGRIND
|
2022-10-30 14:07:41 -07:00
|
|
|
(void)p; (void)size;
|
|
|
|
return true; // when compiled with valgrind we don't fill on purpose
|
2022-12-03 00:23:43 +01:00
|
|
|
#else
|
2021-12-19 21:57:06 +01:00
|
|
|
if(!p)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool result = true;
|
|
|
|
for (size_t i = 0; i < size; ++i) {
|
|
|
|
result &= p[i] == MI_DEBUG_FREED;
|
|
|
|
}
|
|
|
|
return result;
|
2022-12-03 00:23:43 +01:00
|
|
|
#endif
|
2021-12-19 21:57:06 +01:00
|
|
|
}
|
2021-12-19 21:56:52 +01:00
|
|
|
#endif
|