Lines Matching refs:size
51 // BlockAllocator allocates memory block with given size at once, and
53 // requested size is larger than given threshold (plus small internal
99 MemBlock *alloc_mem_block(size_t size) {
100 auto block = new uint8_t[sizeof(MemBlock) + size];
105 mb->end = mb->begin + size;
110 void *alloc(size_t size) {
111 if (size + sizeof(size_t) >= isolation_threshold) {
112 auto len = std::max(static_cast<size_t>(16), size);
113 // We will store the allocated size in size_t field.
122 head->end - head->last < static_cast<ssize_t>(size + sizeof(size_t))) {
126 // We will store the allocated size in size_t field.
129 *sp = size;
132 (reinterpret_cast<intptr_t>(res + size) + 0xf) & ~0xf);
137 // Returns allocated size for memory pointed by |ptr|. We assume
144 // Allocates memory of at least |size| bytes. If |ptr| is nullptr,
145 // this is equivalent to alloc(size). If |ptr| is not nullptr,
146 // obtain the allocated size for |ptr|, assuming that |ptr| was
147 // returned from alloc() or realloc(). If the allocated size is
148 // greater than or equal to size, |ptr| is returned. Otherwise,
149 // allocates at least |size| bytes of memory, and the original
151 void *realloc(void *ptr, size_t size) {
153 return alloc(size);
157 if (size <= alloclen) {
161 auto nalloclen = std::max(size + 1, alloclen * 2);
173 // size of single memory block
184 auto dst = static_cast<uint8_t *>(alloc.alloc(src.size() + 1));
188 return StringRef{dst, src.size()};
201 return concat_string_ref_count(acc + value.size(),
246 value.size() + concat_string_ref_count(0, std::forward<Args>(args)...);
249 auto p = dst + value.size();
263 // Makes a buffer with given size. The resulting byte string might
266 ByteRef make_byte_ref(BlockAllocator &alloc, size_t size) {
267 auto dst = static_cast<uint8_t *>(alloc.alloc(size));
268 return {dst, size};