File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
shared-module/_protomatter Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 2
2
#define MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H
3
3
4
4
#include <stdbool.h>
5
+ #include "py/gc.h"
5
6
#include "py/misc.h"
6
7
#include "supervisor/memory.h"
7
8
8
9
#define _PM_ALLOCATOR _PM_allocator_impl
9
10
#define _PM_FREE (x ) (_PM_free_impl((x)), (x)=NULL, (void)0)
10
11
11
12
static inline void * _PM_allocator_impl (size_t sz ) {
12
- supervisor_allocation * allocation = allocate_memory (align32_size (sz ), true);
13
- if (allocation ) {
14
- return allocation -> ptr ;
15
- } else {
13
+ if (gc_alloc_possible ()) {
16
14
return m_malloc (sz + sizeof (void * ), true);
15
+ } else {
16
+ supervisor_allocation * allocation = allocate_memory (align32_size (sz ), true);
17
+ return allocation ? allocation -> ptr : NULL ;
17
18
}
18
19
}
19
20
You can’t perform that action at this time.
0 commit comments