MCPcopy Create free account
hub / github.com/RenderKit/embree / malloc

Method malloc

kernels/common/alloc.h:848–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

846 }
847
848 void* malloc(MemoryMonitorInterface* device, size_t& bytes_in, size_t align, bool partial)
849 {
850 size_t bytes = bytes_in;
851 assert(align <= maxAlignment);
852 bytes = (bytes+(align-1)) & ~(align-1);
853 if (unlikely(cur+bytes > reserveEnd && !partial)) return nullptr;
854 const size_t i = cur.fetch_add(bytes);
855 if (unlikely(i+bytes > reserveEnd && !partial)) return nullptr;
856 if (unlikely(i > reserveEnd)) return nullptr;
857 bytes_in = bytes = min(bytes,reserveEnd-i);
858
859 if (i+bytes > allocEnd) {
860 if (device) device->memoryMonitor(i+bytes-max(i,allocEnd),true);
861 }
862 return &data[i];
863 }
864
865 void* ptr() {
866 return &data[cur];

Callers

nothing calls this directly

Calls 3

minFunction · 0.50
maxFunction · 0.50
memoryMonitorMethod · 0.45

Tested by

no test coverage detected