BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
Memory utilities
Collaboration diagram for Memory utilities:

Files

file  Memory.hpp

Namespaces

namespace  util
namespace  util::memory

Functions

auto util::memory::page_aligned_alloc (size_t size) -> void *
void util::memory::page_aligned_free (void *mem)
void util::memory::prefetch (const void *mem)

Detailed Description

Memory handling utility functions used throughout the code.

Function Documentation

◆ page_aligned_alloc()

auto util::memory::page_aligned_alloc ( size_t size) -> void *
nodiscard

Allocates memory aligned by page size, with a minimum alignment of 4096 bytes. Memory allocated by this function must be freed by calling page_aligned_free(). Returns nullptr if the memory could not be allocated.

See also
page_aligned_free()

◆ page_aligned_free()

void util::memory::page_aligned_free ( void * mem)

Frees page-aligned memory allocated by page_aligned_alloc(). This is a no-op if mem is nullptr.

See also
page_aligned_alloc()

◆ prefetch()

void util::memory::prefetch ( const void * mem)

Hints the CPU to prefetch the page that the given memory address is on. This function is nonblocking, and may be a no-op depending on the target platform.