File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 26
26
27
27
#include <stdint.h>
28
28
#include <stdio.h>
29
+ #include <errno.h>
29
30
#include "py/mphal.h"
30
31
#include "py/gc.h"
31
32
32
33
// Functions for external libs like axTLS, BerkeleyDB, etc.
33
34
34
35
void * malloc (size_t size ) {
35
- return gc_alloc (size , false);
36
+ void * p = gc_alloc (size , false);
37
+ if (p == NULL ) {
38
+ // POSIX requires ENOMEM to be set in case of error
39
+ errno = ENOMEM ;
40
+ }
41
+ return p ;
36
42
}
37
43
void free (void * ptr ) {
38
44
gc_free (ptr );
39
45
}
40
46
void * calloc (size_t nmemb , size_t size ) {
41
- return m_malloc0 (nmemb * size );
47
+ return malloc (nmemb * size );
42
48
}
43
49
void * realloc (void * ptr , size_t size ) {
44
- return gc_realloc (ptr , size , true);
50
+ void * p = gc_realloc (ptr , size , true);
51
+ if (p == NULL ) {
52
+ // POSIX requires ENOMEM to be set in case of error
53
+ errno = ENOMEM ;
54
+ }
55
+ return p ;
45
56
}
46
57
47
58
#define PLATFORM_HTONL (_n ) ((uint32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) ))
You can’t perform that action at this time.
0 commit comments