File: os_memory.c

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 (39 lines) | stat: -rw-r--r-- 803 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
34
35
36
37
38
39
/* SPDX-License-Identifier: GPL-3.0-or-later
 * Copyright © 2022-2026 The TokTok team.
 */
#include "os_memory.h"

#include <stdlib.h>

#include "attributes.h"
#include "mem.h"

static void *os_malloc(void *_Nonnull self, uint32_t size)
{
    // cppcheck-suppress misra-c2012-21.3
    return malloc(size);
}

static void *os_realloc(void *_Nonnull self, void *_Nullable ptr, uint32_t size)
{
    // cppcheck-suppress misra-c2012-21.3
    return realloc(ptr, size);
}

static void os_dealloc(void *_Nonnull self, void *_Nullable ptr)
{
    // cppcheck-suppress misra-c2012-21.3
    free(ptr);
}

static const Memory_Funcs os_memory_funcs = {
    os_malloc,
    os_realloc,
    os_dealloc,
};
const Memory os_memory_obj = {&os_memory_funcs};

const Memory *os_memory(void)
{
    return &os_memory_obj;
}