Skip to content

Commit a86588b

Browse files
committed
Finish release 0.5-2
2 parents d3ee8f8 + 1cf9079 commit a86588b

8 files changed

Lines changed: 25 additions & 8 deletions

File tree

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ script:
2323
- mkdir $CXX && cd $CXX
2424
- ../cmake-3.3.1-Linux-x86_64/bin/cmake -DCMAKE_BUILD_TYPE=$build_type -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Wno-parentheses" ../
2525
- ../cmake-3.3.1-Linux-x86_64/bin/cmake --build .
26-
- ./test/foonathan_memory_test
26+
- ./test/foonathan_memory_test
27+
- ./test/foonathan_memory_profiling 1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ In addition:
4040
## Basic example
4141

4242
```cpp
43-
include <algorithm>
43+
#include <algorithm>
4444
#include <iostream>
4545
#include <iterator>
4646

doc/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The concepts of this library are defined are [here](md_doc_concepts.html).
3838
## Basic example
3939

4040
```cpp
41-
include <algorithm>
41+
#include <algorithm>
4242
#include <iostream>
4343
#include <iterator>
4444

src/detail/free_list.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ void* ordered_free_memory_list::allocate(std::size_t n) FOONATHAN_NOEXCEPT
479479
xor_list_change(i.next, i.last, i.prev); // change prev pointer from i.next to i.prev
480480
capacity_ -= i.size(actual_size);
481481

482-
if (less(i.prev, last_dealloc_) && less(last_dealloc_, i.next))
482+
// if last_dealloc_ points into the array being removed
483+
if (less_equal(i.first, last_dealloc_) && less_equal(last_dealloc_, i.last))
483484
{
484485
// move last_dealloc just outside range
485486
last_dealloc_ = i.next;

src/detail/free_list_utils.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ namespace foonathan { namespace memory
122122
#endif
123123
}
124124

125+
inline bool less_equal(void *a, void *b) FOONATHAN_NOEXCEPT
126+
{
127+
return a == b || less(a, b);
128+
}
129+
125130
inline bool greater(void *a, void *b) FOONATHAN_NOEXCEPT
126131
{
127132
#if FOONATHAN_HOSTED_IMPLEMENTATION
@@ -130,6 +135,11 @@ namespace foonathan { namespace memory
130135
return to_int(a) < to_int(b);
131136
#endif
132137
}
138+
139+
inline bool greater_equal(void *a, void *b) FOONATHAN_NOEXCEPT
140+
{
141+
return a == b || greater(a, b);
142+
}
133143
} // namespace detail
134144
}} // namespace foonathan::memory
135145

src/detail/small_free_list.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,10 @@ chunk* small_free_memory_list::find_chunk_impl(std::size_t n) FOONATHAN_NOEXCEPT
344344
return c;
345345

346346
cur_forward = cur_forward->next;
347-
cur_backward = cur_backward->next;
348-
} while (cur_forward != cur_backward);
347+
cur_backward = cur_backward->prev;
348+
FOONATHAN_MEMORY_ASSERT(cur_forward != alloc_chunk_);
349+
FOONATHAN_MEMORY_ASSERT(cur_backward != alloc_chunk_);
350+
} while (true);
349351
FOONATHAN_MEMORY_UNREACHABLE("there is memory available somewhere...");
350352
return nullptr;
351353
}

test/benchmark.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ std::size_t measure(F func, Args&&... args)
2626
return std::size_t(duration.count());
2727
}
2828

29-
const std::size_t sample_size = 1024u;
29+
std::size_t sample_size = 1024u;
3030

3131
template<typename F, typename Alloc, typename ... Args>
3232
std::size_t benchmark(F measure_func, Alloc make_alloc, Args&& ... args)

test/profiling.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ void benchmark_array(std::initializer_list<std::size_t> counts,
114114
benchmark_array<Second, Tail...>(counts, node_sizes, array_sizes);
115115
}
116116

117-
int main()
117+
int main(int argc, char *argv[])
118118
{
119+
if (argc >= 2)
120+
sample_size = std::size_t(std::atoi(argv[1]));
121+
119122
class comma_numpunct : public std::numpunct<char>
120123
{
121124
protected:

0 commit comments

Comments
 (0)