| 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]; |
nothing calls this directly
no test coverage detected