add more const declarations (pr #79)

This commit is contained in:
daan 2019-07-08 12:00:59 -07:00
parent 7f0137a617
commit 56bdb2c2f3
4 changed files with 9 additions and 9 deletions

View File

@ -89,7 +89,7 @@ void _mi_stats_done(mi_stats_t* stats);
void* _mi_page_malloc(mi_heap_t* heap, mi_page_t* page, size_t size) mi_attr_noexcept; // called from `_mi_malloc_generic`
void* _mi_heap_malloc_zero(mi_heap_t* heap, size_t size, bool zero);
void* _mi_realloc_zero(void* p, size_t size, bool zero);
mi_block_t* _mi_page_ptr_unalign(const mi_segment_t* segment, const mi_page_t* page, void* p);
mi_block_t* _mi_page_ptr_unalign(const mi_segment_t* segment, const mi_page_t* page, const void* p);
void _mi_free_delayed_block(mi_block_t* block);
#if MI_DEBUG>1

View File

@ -107,8 +107,8 @@ mi_decl_export mi_decl_allocator void* mi_reallocf(void* p, size_t newsize)
mi_decl_export mi_decl_allocator void* mi_rezalloc(void* p, size_t newsize) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2);
mi_decl_export mi_decl_allocator void* mi_recalloc(void* p, size_t count, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(2,3);
mi_decl_export size_t mi_usable_size(void* p) mi_attr_noexcept;
mi_decl_export size_t mi_good_size(size_t size) mi_attr_noexcept;
mi_decl_export size_t mi_usable_size(const void* p) mi_attr_noexcept;
mi_decl_export size_t mi_good_size(size_t size) mi_attr_noexcept;
mi_decl_export void mi_collect(bool force) mi_attr_noexcept;
mi_decl_export void mi_stats_print(FILE* out) mi_attr_noexcept;
@ -240,8 +240,8 @@ mi_decl_export void mi_option_set_default(mi_option_t option, long value);
// mi prefixed implementations of various posix, unix, and C++ allocation functions.
// -----------------------------------------------------------------------------------
mi_decl_export size_t mi_malloc_size(void* p) mi_attr_noexcept;
mi_decl_export size_t mi_malloc_usable_size(void *p) mi_attr_noexcept;
mi_decl_export size_t mi_malloc_size(const void* p) mi_attr_noexcept;
mi_decl_export size_t mi_malloc_usable_size(const void *p) mi_attr_noexcept;
mi_decl_export void mi_cfree(void* p) mi_attr_noexcept;
mi_decl_export int mi_posix_memalign(void** p, size_t alignment, size_t size) mi_attr_noexcept;

View File

@ -27,11 +27,11 @@ terms of the MIT license. A copy of the license can be found in the file
#endif
size_t mi_malloc_size(void* p) mi_attr_noexcept {
size_t mi_malloc_size(const void* p) mi_attr_noexcept {
return mi_usable_size(p);
}
size_t mi_malloc_usable_size(void *p) mi_attr_noexcept {
size_t mi_malloc_usable_size(const void *p) mi_attr_noexcept {
return mi_usable_size(p);
}

View File

@ -177,7 +177,7 @@ static inline void _mi_free_block(mi_page_t* page, bool local, mi_block_t* block
// Adjust a block that was allocated aligned, to the actual start of the block in the page.
mi_block_t* _mi_page_ptr_unalign(const mi_segment_t* segment, const mi_page_t* page, void* p) {
mi_block_t* _mi_page_ptr_unalign(const mi_segment_t* segment, const mi_page_t* page, const void* p) {
mi_assert_internal(page!=NULL && p!=NULL);
size_t diff = (uint8_t*)p - _mi_page_start(segment, page, NULL);
size_t adjust = (diff % page->block_size);
@ -256,7 +256,7 @@ void _mi_free_delayed_block(mi_block_t* block) {
}
// Bytes available in a block
size_t mi_usable_size(void* p) mi_attr_noexcept {
size_t mi_usable_size(const void* p) mi_attr_noexcept {
if (p==NULL) return 0;
const mi_segment_t* segment = _mi_ptr_segment(p);
const mi_page_t* page = _mi_segment_page_of(segment,p);