Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
noop_arena.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_core/noop_arena.h
10//! @brief No-op arena implementation.
11
12#ifndef ROC_CORE_NOOP_ARENA_H_
13#define ROC_CORE_NOOP_ARENA_H_
14
15#include "roc_core/iarena.h"
17
18namespace roc {
19namespace core {
20
21//! Arena implementation that just fails all allocations.
22//! Can be used with containers that have embedded capacity and arena,
23//! but we want them to use only embedded capacity.
24class NoopArenaImpl : public IArena, public NonCopyable<> {
25public:
26 //! Allocate memory no-op.
27 //! @returns
28 //! Always returns null.
29 virtual void* allocate(size_t size);
30
31 //! Deallocate memory no-op.
32 virtual void deallocate(void* ptr);
33
34 //! Compute allocated size no-op.
35 //! @returns
36 //! Always 0.
37 virtual size_t compute_allocated_size(size_t size) const;
38
39 //! Allocated size given pointer no-op.
40 //! @returns
41 //! Always 0.
42 virtual size_t allocated_size(void* ptr) const;
43};
44
45//! Arena implementation that just fails all allocations.
46//! @see NoopArenaImpl.
47static NoopArenaImpl NoopArena;
48
49} // namespace core
50} // namespace roc
51
52#endif // ROC_CORE_NOOP_ARENA_H_
Memory arena interface.
Definition iarena.h:23
Base class for non-copyable objects.
Definition noncopyable.h:23
Arena implementation that just fails all allocations. Can be used with containers that have embedded ...
Definition noop_arena.h:24
virtual void * allocate(size_t size)
Allocate memory no-op.
virtual size_t allocated_size(void *ptr) const
Allocated size given pointer no-op.
virtual void deallocate(void *ptr)
Deallocate memory no-op.
virtual size_t compute_allocated_size(size_t size) const
Compute allocated size no-op.
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Memory arena interface.
Root namespace.
Non-copyable object.