File: memory.hh

package info (click to toggle)
libtoxcore 0.2.22-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,992 kB
  • sloc: ansic: 70,235; cpp: 14,770; sh: 1,576; python: 649; makefile: 255; perl: 39
file content (33 lines) | stat: -rw-r--r-- 729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef C_TOXCORE_TESTING_SUPPORT_PUBLIC_MEMORY_H
#define C_TOXCORE_TESTING_SUPPORT_PUBLIC_MEMORY_H

#include <cstddef>
#include <cstdint>

#include "../../../toxcore/attributes.h"

// Forward declaration
struct Memory;

namespace tox::test {

/**
 * @brief Abstraction over the memory allocator.
 */
class MemorySystem {
public:
    virtual ~MemorySystem();

    virtual void *_Nullable malloc(size_t size) = 0;
    virtual void *_Nullable realloc(void *_Nullable ptr, size_t size) = 0;
    virtual void free(void *_Nullable ptr) = 0;

    /**
     * @brief Returns C-compatible Memory struct.
     */
    virtual struct Memory c_memory() = 0;
};

}  // namespace tox::test

#endif  // C_TOXCORE_TESTING_SUPPORT_PUBLIC_MEMORY_H