Merge branch 'dev' into dev-slice
This commit is contained in:
commit
f32b42e6cc
@ -370,7 +370,7 @@ if(MI_BUILD_SHARED)
|
|||||||
set_target_properties(mimalloc PROPERTIES VERSION ${mi_version} SOVERSION ${mi_version_major} OUTPUT_NAME ${mi_basename} )
|
set_target_properties(mimalloc PROPERTIES VERSION ${mi_version} SOVERSION ${mi_version_major} OUTPUT_NAME ${mi_basename} )
|
||||||
target_compile_definitions(mimalloc PRIVATE ${mi_defines} MI_SHARED_LIB MI_SHARED_LIB_EXPORT)
|
target_compile_definitions(mimalloc PRIVATE ${mi_defines} MI_SHARED_LIB MI_SHARED_LIB_EXPORT)
|
||||||
target_compile_options(mimalloc PRIVATE ${mi_cflags})
|
target_compile_options(mimalloc PRIVATE ${mi_cflags})
|
||||||
target_link_libraries(mimalloc PRIVATE ${mi_libraries} -fsanitize=address)
|
target_link_libraries(mimalloc PRIVATE ${mi_libraries})
|
||||||
target_include_directories(mimalloc PUBLIC
|
target_include_directories(mimalloc PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:${mi_install_incdir}>
|
$<INSTALL_INTERFACE:${mi_install_incdir}>
|
||||||
|
@ -8,11 +8,16 @@ terms of the MIT license. A copy of the license can be found in the file
|
|||||||
#ifndef MIMALLOC_TRACK_H
|
#ifndef MIMALLOC_TRACK_H
|
||||||
#define MIMALLOC_TRACK_H
|
#define MIMALLOC_TRACK_H
|
||||||
|
|
||||||
// ------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------------
|
||||||
// Track memory ranges with macros for tools like Valgrind
|
Track memory ranges with macros for tools like Valgrind
|
||||||
// address sanitizer, or other memory checkers.
|
address sanitizer, or other memory checkers.
|
||||||
// ------------------------------------------------------
|
|
||||||
|
|
||||||
|
The macros are set up such that the size passed to `mi_track_free_size`
|
||||||
|
matches the size of the allocation, or the newsize of a `mi_track_resize` (currently unused though).
|
||||||
|
|
||||||
|
The `size` is either byte precise (and what the user requested) if `MI_PADDING` is enabled,
|
||||||
|
or otherwise it is the full block size which may be larger than the original request.
|
||||||
|
-------------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if MI_VALGRIND
|
#if MI_VALGRIND
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ static mi_decl_noinline void* mi_heap_malloc_zero_aligned_at_fallback(mi_heap_t*
|
|||||||
mi_page_set_has_aligned(page, true);
|
mi_page_set_has_aligned(page, true);
|
||||||
_mi_padding_shrink(page, (mi_block_t*)p, adjust + size);
|
_mi_padding_shrink(page, (mi_block_t*)p, adjust + size);
|
||||||
}
|
}
|
||||||
|
// todo: expand padding if overallocated and p==aligned_p ?
|
||||||
|
|
||||||
mi_assert_internal(mi_page_usable_block_size(_mi_ptr_page(p)) >= adjust + size);
|
mi_assert_internal(mi_page_usable_block_size(_mi_ptr_page(p)) >= adjust + size);
|
||||||
mi_assert_internal(p == _mi_page_ptr_unalign(_mi_ptr_segment(aligned_p), _mi_ptr_page(aligned_p), aligned_p));
|
mi_assert_internal(p == _mi_page_ptr_unalign(_mi_ptr_segment(aligned_p), _mi_ptr_page(aligned_p), aligned_p));
|
||||||
@ -83,9 +84,6 @@ static mi_decl_noinline void* mi_heap_malloc_zero_aligned_at_fallback(mi_heap_t*
|
|||||||
mi_track_free(p);
|
mi_track_free(p);
|
||||||
mi_track_malloc(aligned_p, size, zero);
|
mi_track_malloc(aligned_p, size, zero);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
mi_track_resize(aligned_p, oversize, size);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return aligned_p;
|
return aligned_p;
|
||||||
}
|
}
|
||||||
|
@ -564,7 +564,7 @@ void mi_free(void* p) mi_attr_noexcept
|
|||||||
#if (MI_DEBUG!=0) && !MI_TRACK_ENABLED
|
#if (MI_DEBUG!=0) && !MI_TRACK_ENABLED
|
||||||
memset(block, MI_DEBUG_FREED, mi_page_block_size(page));
|
memset(block, MI_DEBUG_FREED, mi_page_block_size(page));
|
||||||
#endif
|
#endif
|
||||||
mi_track_free(p);
|
mi_track_free_size(p, mi_page_usable_size_of(page,block)); // faster then mi_usable_size as we already now the page and that p is unaligned
|
||||||
mi_block_set_next(page, block, page->local_free);
|
mi_block_set_next(page, block, page->local_free);
|
||||||
page->local_free = block;
|
page->local_free = block;
|
||||||
if mi_unlikely(--page->used == 0) { // using this expression generates better code than: page->used--; if (mi_page_all_free(page))
|
if mi_unlikely(--page->used == 0) { // using this expression generates better code than: page->used--; if (mi_page_all_free(page))
|
||||||
|
Loading…
Reference in New Issue
Block a user