diff --git a/bin/readme.md b/bin/readme.md index f08b2e87..18831d04 100644 --- a/bin/readme.md +++ b/bin/readme.md @@ -3,7 +3,7 @@ We use a separate redirection DLL to override mimalloc on Windows such that we redirect all malloc/free calls that go through the (dynamic) C runtime allocator, including those from other DLL's or libraries. As it intercepts all allocation calls on a low level, -it can be used reliably on large programs that include other 3rd party components. +it can be used on large programs that include other 3rd party components. There are four requirements to make the overriding work well: 1. Use the C-runtime library as a DLL (using the `/MD` or `/MDd` switch). diff --git a/readme.md b/readme.md index f1dd3965..30875b63 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,8 @@ without code changes, for example, on dynamically linked ELF-based systems (Linu ``` > LD_PRELOAD=/usr/lib/libmimalloc.so myprogram ``` -It also includes a robust way to override the default allocator in [Windows](#override_on_windows). Notable aspects of the design include: +It also includes a way to dynamically override the default allocator in [Windows](#override_on_windows). +Notable aspects of the design include: - __small and consistent__: the library is about 10k LOC using simple and consistent data structures. This makes it very suitable @@ -478,7 +479,7 @@ the [shell](https://stackoverflow.com/questions/43941322/dyld-insert-libraries-i We use a separate redirection DLL to override mimalloc on Windows such that we redirect all malloc/free calls that go through the (dynamic) C runtime allocator, including those from other DLL's or libraries. As it intercepts all allocation calls on a low level, -it can be used reliably on large programs that include other 3rd party components. +it can be used on large programs that include other 3rd party components. There are four requirements to make the overriding work well: 1. Use the C-runtime library as a DLL (using the `/MD` or `/MDd` switch). diff --git a/src/segment-map.c b/src/segment-map.c index 43cb3bd9..2f68f8c4 100644 --- a/src/segment-map.c +++ b/src/segment-map.c @@ -28,9 +28,9 @@ terms of the MIT license. A copy of the license can be found in the file #define MI_SEGMENT_MAP_PART_SIZE (MI_INTPTR_SIZE*MI_KiB - 128) // 128 > sizeof(mi_memid_t) ! #define MI_SEGMENT_MAP_PART_BITS (8*MI_SEGMENT_MAP_PART_SIZE) #define MI_SEGMENT_MAP_PART_ENTRIES (MI_SEGMENT_MAP_PART_SIZE / MI_INTPTR_SIZE) -#define MI_SEGMENT_MAP_PART_BIT_SPAN (MI_SEGMENT_ALIGN) +#define MI_SEGMENT_MAP_PART_BIT_SPAN (MI_SEGMENT_ALIGN) // memory area covered by 1 bit -#if (MI_SEGMENT_PART_BITS < (MI_SEGMENT_MAP_MAX_ADDRESS / MI_SEGMENT_MAP_PART_BIT_SPAN)) // prevent overflow on 32-bit (issue #1017) +#if (MI_SEGMENT_MAP_PART_BITS < (MI_SEGMENT_MAP_MAX_ADDRESS / MI_SEGMENT_MAP_PART_BIT_SPAN)) // prevent overflow on 32-bit (issue #1017) #define MI_SEGMENT_MAP_PART_SPAN (MI_SEGMENT_MAP_PART_BITS * MI_SEGMENT_MAP_PART_BIT_SPAN) #else #define MI_SEGMENT_MAP_PART_SPAN MI_SEGMENT_MAP_MAX_ADDRESS @@ -58,7 +58,7 @@ static mi_segmap_part_t* mi_segment_map_index_of(const mi_segment_t* segment, bo mi_segmap_part_t* part = mi_atomic_load_ptr_relaxed(mi_segmap_part_t, &mi_segment_map[segindex]); // allocate on demand to reduce .bss footprint - if (part == NULL) { + if mi_unlikely(part == NULL) { if (!create_on_demand) return NULL; mi_memid_t memid; part = (mi_segmap_part_t*)_mi_os_alloc(sizeof(mi_segmap_part_t), &memid);