mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-17 05:44:08 -07:00
28 lines
556 B
C++
28 lines
556 B
C++
#include "precompiled.h"
|
|
#include "io_buf.h"
|
|
|
|
#include "lib/allocators/allocators.h" // AllocatorChecker
|
|
|
|
#ifndef NDEBUG
|
|
static AllocatorChecker allocatorChecker;
|
|
#endif
|
|
|
|
IoBuf io_buf_Allocate(size_t size)
|
|
{
|
|
void* p = page_aligned_alloc(size);
|
|
if(!p)
|
|
throw std::bad_alloc();
|
|
#ifndef NDEBUG
|
|
allocatorChecker.notify_alloc(p, size);
|
|
#endif
|
|
return (IoBuf)p;
|
|
}
|
|
|
|
void io_buf_Deallocate(IoBuf buf, size_t size)
|
|
{
|
|
void* p = (void*)buf;
|
|
#ifndef NDEBUG
|
|
allocatorChecker.notify_free(p, size);
|
|
#endif
|
|
page_aligned_free(p, size);
|
|
}
|