a59eafbc9d
* fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * Initial add of @stickbreaker i2c * Add log_n * fix warnings when log is off * i2c code clean up and reorganization * add flags to interrupt allocator * fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * fix errors with latest IDF * fix debug optimization (#1365) incorrect optimization for debugging tick markers. * Fix some missing BT header * Change BTSerial log calls * Update BLE lib * Arduino-ESP32 release management scripted (#1515) * Calculate an absolute path for a custom partitions table (#1452) * * Arduino-ESP32 release management scripted (ready-to-merge) * * secure env for espressif/arduino-esp32 * * build tests enabled * gitter webhook enabled * * gitter room link fixed * better comment * * filepaths fixed * BT Serial adjustments * * don't run sketch builds & tests for tagged builds * Return false from WiFi.hostByName() if hostname is not resolved * Free BT Memory when BT is not used * WIFI_MODE_NULL is not supported anymore * Select some key examples to build with PlatformIO to save some time * Update BLE lib * Fixed BLE lib * Major WiFi overhaul - auto reconnect on connection loss now works - moved to event groups - some code clean up and procedure optimizations - new methods to get a more elaborate system ststus * Add cmake tests to travis * Add initial AsyncUDP * Add NetBIOS lib and fix CMake includes * Add Initial WebServer * Fix WebServer and examples * travis not quiting on build fail * Try different travis build * Update IDF to aaf1239 * Fix WPS Example * fix script permission and add some fail tests to sketch builder * Add missing space in WiFiClient::write(Stream &stream)
154 lines
5.8 KiB
C
154 lines
5.8 KiB
C
/******************************************************************************
|
|
*
|
|
* Copyright (C) 2014 Google, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at:
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
******************************************************************************/
|
|
|
|
#ifndef _ALLOCATOR_H_
|
|
#define _ALLOCATOR_H_
|
|
|
|
#include <stddef.h>
|
|
#include <stdlib.h>
|
|
#include "esp_heap_caps.h"
|
|
#include "sdkconfig.h"
|
|
|
|
typedef void *(*alloc_fn)(size_t size);
|
|
typedef void (*free_fn)(void *ptr);
|
|
|
|
typedef struct {
|
|
alloc_fn alloc;
|
|
free_fn free;
|
|
} allocator_t;
|
|
|
|
// allocator_t abstractions for the osi_*alloc and osi_free functions
|
|
extern const allocator_t allocator_malloc;
|
|
extern const allocator_t allocator_calloc;
|
|
|
|
char *osi_strdup(const char *str);
|
|
|
|
void *osi_malloc_func(size_t size);
|
|
void *osi_calloc_func(size_t size);
|
|
void osi_free_func(void *ptr);
|
|
|
|
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
|
|
|
|
void osi_mem_dbg_init(void);
|
|
void osi_mem_dbg_record(void *p, int size, const char *func, int line);
|
|
void osi_mem_dbg_clean(void *p, const char *func, int line);
|
|
void osi_mem_dbg_show(void);
|
|
|
|
#if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST
|
|
#define osi_malloc(size) \
|
|
({ \
|
|
void *p; \
|
|
p = heap_caps_malloc_prefer(size, 2, \
|
|
MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \
|
|
MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \
|
|
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
|
(void *)p; \
|
|
})
|
|
|
|
#define osi_calloc(size) \
|
|
({ \
|
|
void *p; \
|
|
p = heap_caps_calloc_prefer(1, size, 2, \
|
|
MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \
|
|
MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \
|
|
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
|
(void *)p; \
|
|
})
|
|
|
|
#else
|
|
|
|
#define osi_malloc(size) \
|
|
({ \
|
|
void *p; \
|
|
p = malloc((size)); \
|
|
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
|
(void *)p; \
|
|
})
|
|
|
|
#define osi_calloc(size) \
|
|
({ \
|
|
void *p; \
|
|
p = calloc(1, (size)); \
|
|
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
|
(void *)p; \
|
|
})
|
|
|
|
#endif /* #if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST */
|
|
|
|
|
|
#if 0
|
|
#define osi_malloc(size) \
|
|
do { \
|
|
void *p; \
|
|
\
|
|
#if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST \
|
|
p = heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \
|
|
#else \
|
|
p = malloc((size)); \
|
|
#endif /* #if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST */ \
|
|
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
|
(void *)p; \
|
|
}while(0)
|
|
|
|
#define osi_calloc(size) \
|
|
do { \
|
|
void *p; \
|
|
\
|
|
#if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST \
|
|
p = heap_caps_calloc_prefer(1, size, 2, \
|
|
MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \
|
|
MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \
|
|
#else \
|
|
p = calloc(1, (size)); \
|
|
#endif /* #if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST */ \
|
|
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
|
(void *)p; \
|
|
} while(0)
|
|
#endif
|
|
|
|
#define osi_free(ptr) \
|
|
do { \
|
|
void *tmp_point = (void *)(ptr); \
|
|
osi_mem_dbg_clean(tmp_point, __func__, __LINE__); \
|
|
free(tmp_point); \
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST
|
|
#define osi_malloc(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
|
|
#define osi_calloc(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
|
|
#else
|
|
#define osi_malloc(size) malloc((size))
|
|
#define osi_calloc(size) calloc(1, (size))
|
|
#endif /* #if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST */
|
|
#define osi_free(p) free((p))
|
|
|
|
#endif /* CONFIG_BLUEDROID_MEM_DEBUG */
|
|
|
|
#define FREE_AND_RESET(a) \
|
|
do { \
|
|
if (a) { \
|
|
osi_free(a); \
|
|
a = NULL; \
|
|
} \
|
|
}while (0)
|
|
|
|
|
|
#endif /* _ALLOCATOR_H_ */
|