MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / allocate

Function allocate

lite/test/test_network_c.cpp:32–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30std::atomic_size_t m_nr_allocated{0};
31
32void* allocate(LiteDeviceType device, int, size_t size, size_t align) {
33 LITE_ASSERT(device == LiteDeviceType::LITE_CPU);
34 m_nr_left++;
35 m_nr_allocated++;
36#ifdef WIN32
37 return _aligned_malloc(size, align);
38#elif defined(__ANDROID__) || defined(ANDROID) || defined(__OHOS__)
39 return memalign(align, size);
40#else
41 void* ptr = nullptr;
42 auto err = posix_memalign(&ptr, align, size);
43 mgb_assert(!err, "failed to malloc %zu bytes with align %zu", size, align);
44 return ptr;
45#endif
46}
47
48void free(LiteDeviceType device, int, void* ptr) {
49 m_nr_left--;

Callers 2

execMethod · 0.85
exectMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected