MCPcopy Create free account
hub / github.com/TuGraph-family/tugraph-db / alloc_buffer

Function alloc_buffer

src/lgraph_api/lgraph_utils.cpp:159–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159void* alloc_buffer(size_t bytes) {
160 void* buffer;
161#if USE_VALGRIND
162 buffer = malloc(bytes);
163 if (!buffer) {
164 throw std::bad_alloc();
165 }
166#else
167 buffer = mmap(nullptr, bytes, PROT_READ | PROT_WRITE,
168 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
169 if (buffer == MAP_FAILED) {
170 throw std::runtime_error("memory allocation failed");
171 }
172#endif
173 return buffer;
174}
175
176void dealloc_buffer(void* buffer, size_t bytes) {
177#if USE_VALGRIND

Callers 7

TEST_FFunction · 0.85
StringTextFileReaderMethod · 0.85
InitMethod · 0.85
TextFileReaderMethod · 0.85
BinaryFileReaderMethod · 0.85
ArrayTextReaderMethod · 0.85
ArrayBinaryReaderMethod · 0.85

Calls

no outgoing calls

Tested by 1

TEST_FFunction · 0.68