0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-25 21:38:18 +02:00

ircd::allocator: Add and fix attribute related.

This commit is contained in:
Jason Volk 2019-02-28 11:12:00 -08:00
parent 54224e9679
commit 7b1ed2e715
2 changed files with 16 additions and 6 deletions

View file

@ -217,7 +217,9 @@ struct ircd::allocator::fixed<T, SIZE>::allocator
return &x;
}
pointer allocate(std::nothrow_t, const size_type &n, const const_pointer &hint = nullptr)
pointer
__attribute__((malloc, warn_unused_result))
allocate(std::nothrow_t, const size_type &n, const const_pointer &hint = nullptr)
{
const auto base(reinterpret_cast<pointer>(s->buf.data()));
const uint hintpos(hint? hint - base : -1);
@ -225,7 +227,9 @@ struct ircd::allocator::fixed<T, SIZE>::allocator
return s->in_range(ret)? ret : nullptr;
}
pointer allocate(const size_type &n, const const_pointer &hint = nullptr)
pointer
__attribute__((malloc, returns_nonnull, warn_unused_result))
allocate(const size_type &n, const const_pointer &hint = nullptr)
{
const auto base(reinterpret_cast<pointer>(s->buf.data()));
const uint hintpos(hint? hint - base : -1);
@ -346,7 +350,9 @@ struct ircd::allocator::dynamic<T>::allocator
auto address(reference x) const { return &x; }
auto address(const_reference x) const { return &x; }
pointer allocate(const size_type &n, const const_pointer &hint = nullptr)
pointer
__attribute__((malloc, returns_nonnull, warn_unused_result))
allocate(const size_type &n, const const_pointer &hint = nullptr)
{
const uint hintpos(hint? hint - s->buf : -1);
return s->buf + s->state::allocate(n, hintpos);
@ -461,7 +467,9 @@ struct ircd::allocator::node<T>::allocator
new (p) T(val);
}
pointer allocate(const size_type &n, const const_pointer &hint = nullptr)
pointer
__attribute__((returns_nonnull, warn_unused_result))
allocate(const size_type &n, const const_pointer &hint = nullptr)
{
assert(n == 1);
assert(hint == nullptr);
@ -563,7 +571,9 @@ struct ircd::allocator::twolevel<T, L0_SIZE>::allocator
return &x;
}
pointer allocate(const size_type &n, const const_pointer &hint = nullptr)
pointer
__attribute__((malloc, returns_nonnull, warn_unused_result))
allocate(const size_type &n, const const_pointer &hint = nullptr)
{
assert(s);
return

View file

@ -433,8 +433,8 @@ ircd::allocator::operator+=(profile &a,
#ifdef RB_PROF_ALLOC // --------------------------------------------------
__attribute__((alloc_size(1), malloc, returns_nonnull))
void *
__attribute__((alloc_size(1), malloc, returns_nonnull))
operator new(const size_t size)
{
void *const &ptr(::malloc(size));