一呼百應, "one call, a hundred responses"
Loading...
Searching...
No Matches
memory.hpp File Reference
#include <type_traits>
#include <cstring>
#include <memory>
#include <sys/mman.h>
#include "attributes/common.hpp"
#include "attributes/strings.hpp"
#include "attributes/null_safety.hpp"
Include dependency graph for memory.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ein::c_munmap
 std::unique_ptr Deleter for memory mapped data More...
 
struct  ein::c_free
 std::unique_ptr Deleter that calls free() More...
 

Namespaces

namespace  ein
 

Concepts

concept  ein::trivially_destructible
 a type where the destructor does no work, and therefore it is safe to simply discard.
 

Typedefs

using ein::mmap_ptr = std::unique_ptr<void,c_munmap>
 memory mapped data, managed by std::unique_ptr. calls munmap to free.
 
template<trivially_destructible T>
using ein::unique_c_ptr = std::unique_ptr<T, c_free>
 a unique_ptr managed c pointer, deleted by free()
 
using ein::unique_str = unique_c_ptr<char const>
 a c string, managed by unique_ptr
 

Functions

mmap_ptr ein::make_mmap_ptr (void *p, size_t size) noexcept
 construct a mmap_ptr using a base pointer and its size for munmap
 
unique_str ein::dup (char const *str) noexcept
 duplicate a C string using strdup and manage it as a unique_str
 

Detailed Description

SPDX-FileType: Source
SPDX-FileCopyrightText: 2024 Edward Kmett <ekmett@gmail.com>
SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0

Definition in file memory.hpp.