로딩중...
검색중...
일치하는것 없음
chunk.hpp
이 파일의 문서화 페이지로 가기
1
2#pragma once
3
5
6namespace by {
7
57 class _nout chunk: public allocator {
58 BY(ME(chunk, allocator))
59
60 public:
61 // chunk:
62 static constexpr ncnt MIN_SZ = 20;
63
64 public:
65 explicit chunk(ncnt blockSz = 1, ncnt sz = MIN_SZ);
66 ~chunk();
67
68 public:
69 void* operator[](nidx n);
70 const void* operator[](nidx n) const BY_CONST_FUNC(operator[](n));
71
72 public:
73 void* get(nidx n) { return _get(n); }
74
75 // allocator:
76 void* new1() override;
77 nbool del(void* used, ncnt) override;
78 // MemoryHaver:
79 ncnt len() const override;
80 ncnt size() const override;
81 nbool rel() override;
82
83 using super::has;
89 nbool has(const instance& it) const override;
90
91 protected:
96 void* _get(nidx n) override;
97 nuchar* _getHeap();
98 const nuchar* _getHeap() const BY_CONST_FUNC(_getHeap())
99 nbool _resize(ncnt newSz);
100
101 private:
102 // chunk:
103 const nuchar* _getEOB() const BY_CONST_FUNC(_getEOB())
104 nuchar* _getEOB();
105 nbool _index(nidx start);
106 ncnt _getRealBlkSize();
107 void* _allocHeap(ncnt new_sz);
108 nbool _freeHeap(nuchar** heap);
109
110 nidx _head;
111 ncnt _len, _sz;
112 nuchar* _heap;
113 };
114} // namespace by
Abstract allocator interface for memory management
Definition allocator.hpp:21
Memory chunk for block-based allocation
Definition chunk.hpp:57
nbool has(const instance &it) const override
Checks if this chunk contains the memory allocated for the given instance.
void * _get(nidx n) override
Base class for all managed instances in memlite system
Definition instance.hpp:41
Weak reference smart pointer with type-safe access
Definition tweak.hpp:16
to Top