Coverage Report

Created: 2026-10-24 08:16

/work/toxcore/os_memory.c
Line
Count
Source
1
/* SPDX-License-Identifier: GPL-3.0-or-later
2
 * Copyright © 2022-2026 The TokTok team.
3
 */
4
#include "os_memory.h"
5
6
#include <stdlib.h>
7
8
#include "attributes.h"
9
#include "mem.h"
10
11
static void *_Nullable os_malloc(void *_Nonnull self, uint32_t size)
12
3.58M
{
13
    // cppcheck-suppress misra-c2012-21.3
14
3.58M
    return malloc(size);
15
3.58M
}
16
17
static void *_Nullable os_realloc(void *_Nonnull self, void *_Nullable ptr, uint32_t size)
18
33.0k
{
19
    // cppcheck-suppress misra-c2012-21.3
20
33.0k
    return realloc(ptr, size);
21
33.0k
}
22
23
static void os_dealloc(void *_Nonnull self, void *_Nullable ptr)
24
4.63M
{
25
    // cppcheck-suppress misra-c2012-21.3
26
4.63M
    free(ptr);
27
4.63M
}
28
29
static const Memory_Funcs os_memory_funcs = {
30
    os_malloc,
31
    os_realloc,
32
    os_dealloc,
33
};
34
const Memory os_memory_obj = {&os_memory_funcs};
35
36
const Memory *os_memory(void)
37
2.11k
{
38
2.11k
    return &os_memory_obj;
39
2.11k
}