forked from getsentry/sentry-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentry_alloc.c
More file actions
34 lines (31 loc) · 709 Bytes
/
Copy pathsentry_alloc.c
File metadata and controls
34 lines (31 loc) · 709 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
#include "sentry_alloc.h"
#include "sentry_sync.h"
#include <stdlib.h>
#include <string.h>
/* on unix platforms we add support for a simplistic page allocator that can
be enabled to make code async safe */
#if defined(SENTRY_PLATFORM_UNIX)
# include "sentry_unix_pageallocator.h"
# define WITH_PAGE_ALLOCATOR
#endif
void *
sentry_malloc(size_t size)
{
#ifdef WITH_PAGE_ALLOCATOR
if (sentry__page_allocator_enabled()) {
return sentry__page_allocator_alloc(size);
}
#endif
return malloc(size);
}
void
sentry_free(void *ptr)
{
#ifdef WITH_PAGE_ALLOCATOR
/* page allocator can't free */
if (sentry__page_allocator_enabled()) {
return;
}
#endif
free(ptr);
}