File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed
src/tools/fdsdump/src/aggregator Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ set(AGGREGATOR_SRC
1010 printer.cpp
1111 jsonPrinter.cpp
1212 tablePrinter.cpp
13+ stdAllocator.cpp
1314)
1415
1516add_library (aggregator_obj OBJECT ${AGGREGATOR_SRC} )
Original file line number Diff line number Diff line change 1+ /* *
2+ * @file
3+ * @author Michal Sedlak <[email protected] > 4+ * @brief Simple allocator
5+ */
6+
7+ #include < aggregator/stdAllocator.hpp>
8+
9+ #include < cassert>
10+
11+ namespace fdsdump {
12+ namespace aggregator {
13+
14+ uint8_t *
15+ StdAllocator::allocate (size_t size)
16+ {
17+ m_blocks.push_back (std::unique_ptr<uint8_t []>(new uint8_t [size]));
18+ return m_blocks.back ().get ();
19+ }
20+
21+ } // aggregator
22+ } // fdsdump
Original file line number Diff line number Diff line change 1+ /* *
2+ * @file
3+ * @author Michal Sedlak <[email protected] > 4+ * @brief Simple allocator
5+ */
6+ #pragma once
7+
8+ #include < memory>
9+ #include < vector>
10+
11+ namespace fdsdump {
12+ namespace aggregator {
13+
14+ /* *
15+ * @brief A simple allocator.
16+ *
17+ */
18+ class StdAllocator {
19+ public:
20+ StdAllocator () {}
21+
22+ /* * @brief Disallow copy constructor. */
23+ StdAllocator (const StdAllocator &) = delete ;
24+ /* * @brief Disallow move constructor. */
25+ StdAllocator (StdAllocator &&) = delete ;
26+
27+ /* *
28+ * @brief Allocate bytes.
29+ * @param[in] size The number of bytes
30+ * @return Pointer to the bytes
31+ */
32+ uint8_t *allocate (size_t size);
33+
34+ private:
35+ std::vector<std::unique_ptr<uint8_t []>> m_blocks;
36+ };
37+
38+ } // aggregator
39+ } // fdsdump
You can’t perform that action at this time.
0 commit comments