1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

Fix malloc/free references

This commit is contained in:
Ivan Grokhotkov
2014-12-01 00:34:28 +03:00
parent f5f851c978
commit 22b88f73c2
7 changed files with 37 additions and 10 deletions

View File

@ -46,6 +46,11 @@ extern void (*__init_array_end)(void);
static cont_t g_cont;
static os_event_t g_loop_queue[LOOP_QUEUE_SIZE];
extern "C" void abort()
{
while(1){}
}
extern "C" void esp_yield()
{
cont_yield(&g_cont);

View File

@ -17,20 +17,27 @@
*/
#include <stdlib.h>
extern "C" {
#include "ets_sys.h"
#include "os_type.h"
#include "osapi.h"
#include "mem.h"
#include "user_interface.h"
}
void *operator new(size_t size) {
return malloc(size);
return os_malloc(size);
}
void *operator new[](size_t size) {
return malloc(size);
return os_malloc(size);
}
void operator delete(void * ptr) {
free(ptr);
os_free(ptr);
}
void operator delete[](void * ptr) {
free(ptr);
os_free(ptr);
}

View File

@ -1,37 +1,47 @@
#include <stdlib.h>
#include "stdlib_noniso.h"
char * itoa (int val, char *s, int radix)
long atol_internal(const char* s)
{
return 0;
}
float atof_internal(const char* s)
{
return 0;
}
char * itoa (int val, char *s, int radix)
{
*s = 0;
return s;
}
char * ltoa (long val, char *s, int radix)
char * ltoa (long val, char *s, int radix)
{
*s = 0;
return s;
}
char * utoa (unsigned int val, char *s, int radix)
char * utoa (unsigned int val, char *s, int radix)
{
*s = 0;
return s;
}
char * ultoa (unsigned long val, char *s, int radix)
char * ultoa (unsigned long val, char *s, int radix)
{
*s = 0;
return s;
}
char * dtostre (double __val, char *__s, unsigned char __prec, unsigned char __flags)
char * dtostre (double __val, char *__s, unsigned char __prec, unsigned char __flags)
{
*__s = 0;
return __s;
}
char * dtostrf (double __val, signed char __width, unsigned char __prec, char *__s)
char * dtostrf (double __val, signed char __width, unsigned char __prec, char *__s)
{
*__s = 0;
return __s;

View File

@ -5,6 +5,9 @@
extern "C"{
#endif
long atol_internal(const char*);
float atof_internal(const char*);
char* itoa (int val, char *s, int radix);

0
hardware/arduino/esp8266/cores/esp8266/user_config.h Executable file → Normal file
View File

1
hardware/tools/esp8266/sdk/include/ets_sys.h Executable file → Normal file
View File

@ -83,6 +83,7 @@ typedef struct _ETSTIMER_ {
void ets_isr_attach(int routine, void* something, void *buff);
void *pvPortMalloc(size_t xWantedSize);
void *pvPortRealloc(void* ptr, size_t xWantedSize);
void pvPortFree(void *ptr);
void *vPortMalloc(size_t xWantedSize);
void vPortFree(void *ptr);

1
hardware/tools/esp8266/sdk/include/mem.h Executable file → Normal file
View File

@ -8,5 +8,6 @@
#define os_malloc pvPortMalloc
#define os_free vPortFree
#define os_zalloc pvPortZalloc
#define os_realloc pvPortRealloc
#endif