LexLeo 0.0.0-dev+f8e5087-dirty
Technical documentation
Loading...
Searching...
No Matches
osal_mem_ops.c
Go to the documentation of this file.
1// src/foundation/osal/osal_mem/src/internal/osal_mem_ops.c
2
4
7
8static void *libc_malloc(size_t s) { return malloc(s); }
9static void libc_free(void *p) { free(p); }
10static void *libc_calloc(size_t n, size_t s) { return calloc(n, s); }
11static void *libc_realloc(void *p, size_t s) { return realloc(p, s); }
12
13static char *libc_strdup(const char *s)
14{
15 if (!s) return NULL;
16 size_t len = strlen(s) + 1;
17 char *p = (char *)malloc(len);
18 if (!p) return NULL;
19 memcpy(p, s, len);
20 return p;
21}
22
24{
25 static const osal_mem_ops_t OPS = {
27 .free = libc_free,
28 .calloc = libc_calloc,
29 .realloc = libc_realloc,
30 .strdup = libc_strdup,
31 };
32 return &OPS;
33}
static void libc_free(void *p)
Definition osal_mem_ops.c:9
static void * libc_malloc(size_t s)
Definition osal_mem_ops.c:8
static char * libc_strdup(const char *s)
const osal_mem_ops_t * osal_mem_default_ops(void)
static void * libc_calloc(size_t n, size_t s)
static void * libc_realloc(void *p, size_t s)
void *(* malloc)(size_t size)