fix warnings

This commit is contained in:
daanx 2023-05-02 18:31:07 -07:00
parent 8fffc92e15
commit 7897433412
2 changed files with 5 additions and 30 deletions

View file

@ -886,7 +886,7 @@ int _mi_prim_remap_reserve(size_t size, bool* is_pinned, void** base, void** rem
int _mi_prim_remap_to(void* base, void* addr, size_t size, void* newaddr, size_t newsize, bool* extend_is_zero, void** remap_info, void** new_remap_info) int _mi_prim_remap_to(void* base, void* addr, size_t size, void* newaddr, size_t newsize, bool* extend_is_zero, void** remap_info, void** new_remap_info)
{ {
mi_assert_internal(base <= addr); mi_assert_internal(base <= addr); MI_UNUSED_RELEASE(base);
mi_assert_internal((size % _mi_os_page_size()) == 0); mi_assert_internal((size % _mi_os_page_size()) == 0);
mi_assert_internal((newsize % _mi_os_page_size()) == 0); mi_assert_internal((newsize % _mi_os_page_size()) == 0);
*new_remap_info = NULL; *new_remap_info = NULL;

View file

@ -18,14 +18,13 @@ static void test_reserved(void);
static void negative_stat(void); static void negative_stat(void);
static void alloc_huge(void); static void alloc_huge(void);
static void test_heap_walk(void); static void test_heap_walk(void);
static void test_remap(void); static void test_remap(bool start_remappable);
static void test_remap_realloc(void);
int main() { int main() {
mi_version(); mi_version();
mi_stats_reset(); mi_stats_reset();
test_remap_realloc(); test_remap(true);
// detect double frees and heap corruption // detect double frees and heap corruption
// double_free1(); // double_free1();
@ -221,12 +220,12 @@ static void test_heap_walk(void) {
} }
static void test_remap(void) { static void test_remap(bool start_remappable) {
const size_t iterN = 100; const size_t iterN = 100;
const size_t size0 = 64 * 1024 * 1024; const size_t size0 = 64 * 1024 * 1024;
const size_t inc = 1024 * 1024; const size_t inc = 1024 * 1024;
size_t size = size0; size_t size = size0;
uint8_t* p = (uint8_t*)mi_malloc_remappable(size); uint8_t* p = (uint8_t*)(start_remappable ? mi_malloc_remappable(size) : mi_malloc(size));
memset(p, 1, size); memset(p, 1, size);
for (int i = 2; i < iterN; i++) { for (int i = 2; i < iterN; i++) {
p = mi_realloc(p, size + inc); p = mi_realloc(p, size + inc);
@ -245,30 +244,6 @@ static void test_remap(void) {
mi_free(p); mi_free(p);
} }
static void test_remap_realloc(void) {
const size_t iterN = 100;
const size_t size0 = 64 * 1024 * 1024;
const size_t inc = 1024 * 1024;
size_t size = size0;
uint8_t* p = (uint8_t*)mi_malloc(size);
memset(p, 1, size);
for (int i = 2; i < iterN; i++) {
p = mi_realloc(p, size + inc);
memset(p + size, i, inc);
size += inc;
printf("%3d: increased to size %zu\n", i, size);
}
for (int i = 1; i < iterN; i++) {
size_t idx = size0 + ((i - 1) * inc) - 1;
uint8_t v = p[idx];
if (v != i) {
printf("error: corrupted memory in remap_realloc: i=%d, index=0x%zx, value=%u \n", i, idx, v);
abort();
};
}
mi_free(p);
}
// ---------------------------- // ----------------------------
// bin size experiments // bin size experiments