forked from vnmakarov/mir
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmir-alloc-default.c
More file actions
36 lines (29 loc) · 891 Bytes
/
mir-alloc-default.c
File metadata and controls
36 lines (29 loc) · 891 Bytes
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
/* This file is a part of MIR project.
Copyright (C) 2018-2024 Vladimir Makarov <vmakarov.gcc@gmail.com>.
*/
#include <stdlib.h>
#include "mir-alloc.h"
#ifdef __GNUC__
#define ALLOC_UNUSED __attribute__ ((unused))
#else
#define ALLOC_UNUSED
#endif
static void *default_malloc (size_t size, void *user_data ALLOC_UNUSED) {
return malloc (size);
}
static void *default_calloc (size_t num, size_t size, void *user_data ALLOC_UNUSED) {
return calloc (num, size);
}
static void *default_realloc (void *ptr, size_t old_size ALLOC_UNUSED, size_t new_size, void *user_data ALLOC_UNUSED) {
return realloc (ptr, new_size);
}
static void default_free (void *ptr, void *user_data ALLOC_UNUSED) {
free (ptr);
}
static struct MIR_alloc default_alloc = {
.malloc = default_malloc,
.calloc = default_calloc,
.realloc = default_realloc,
.free = default_free,
.user_data = NULL
};