Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UAVCAN UAVCAN_Subscriber
libuavcan/src/uc_dynamic_memory.cpp
- Committer:
- RuslanUrya
- Date:
- 2018-04-14
- Revision:
- 0:dfe6edabb8ec
File content as of revision 0:dfe6edabb8ec:
/* * Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com> */ #include <uavcan/dynamic_memory.hpp> namespace uavcan { /* * LimitedPoolAllocator */ void* LimitedPoolAllocator::allocate(std::size_t size) { if (used_blocks_ < max_blocks_) { used_blocks_++; return allocator_.allocate(size); } else { return UAVCAN_NULLPTR; } } void LimitedPoolAllocator::deallocate(const void* ptr) { allocator_.deallocate(ptr); UAVCAN_ASSERT(used_blocks_ > 0); if (used_blocks_ > 0) { used_blocks_--; } } uint16_t LimitedPoolAllocator::getBlockCapacity() const { return min(max_blocks_, allocator_.getBlockCapacity()); } }