mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 11:17:20 +02:00
fix(dedic_gpio): fix calloc to heap_caps_calloc
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -31,6 +31,7 @@
|
|||||||
#include "hal/dedic_gpio_ll.h"
|
#include "hal/dedic_gpio_ll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DEDIC_GPIO_MEM_ALLOC_CAPS MALLOC_CAP_DEFAULT
|
||||||
|
|
||||||
static const char *TAG = "dedic_gpio";
|
static const char *TAG = "dedic_gpio";
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ static esp_err_t dedic_gpio_build_platform(int core_id)
|
|||||||
// prevent building platform concurrently
|
// prevent building platform concurrently
|
||||||
_lock_acquire(&s_platform_mutexlock[core_id]);
|
_lock_acquire(&s_platform_mutexlock[core_id]);
|
||||||
if (!s_platform[core_id]) {
|
if (!s_platform[core_id]) {
|
||||||
s_platform[core_id] = calloc(1, sizeof(dedic_gpio_platform_t));
|
s_platform[core_id] = (dedic_gpio_platform_t *)heap_caps_calloc(1, sizeof(dedic_gpio_platform_t), DEDIC_GPIO_MEM_ALLOC_CAPS);
|
||||||
if (s_platform[core_id]) {
|
if (s_platform[core_id]) {
|
||||||
// initialize platfrom members
|
// initialize platfrom members
|
||||||
s_platform[core_id]->spinlock = (portMUX_TYPE)portMUX_INITIALIZER_UNLOCKED;
|
s_platform[core_id]->spinlock = (portMUX_TYPE)portMUX_INITIALIZER_UNLOCKED;
|
||||||
@ -205,7 +206,7 @@ esp_err_t dedic_gpio_new_bundle(const dedic_gpio_bundle_config_t *config, dedic_
|
|||||||
ESP_GOTO_ON_ERROR(dedic_gpio_build_platform(core_id), err, TAG, "build platform %d failed", core_id);
|
ESP_GOTO_ON_ERROR(dedic_gpio_build_platform(core_id), err, TAG, "build platform %d failed", core_id);
|
||||||
|
|
||||||
size_t bundle_size = sizeof(dedic_gpio_bundle_t) + config->array_size * sizeof(config->gpio_array[0]);
|
size_t bundle_size = sizeof(dedic_gpio_bundle_t) + config->array_size * sizeof(config->gpio_array[0]);
|
||||||
bundle = calloc(1, bundle_size);
|
bundle = (dedic_gpio_bundle_t *)heap_caps_calloc(1, bundle_size, DEDIC_GPIO_MEM_ALLOC_CAPS);
|
||||||
ESP_GOTO_ON_FALSE(bundle, ESP_ERR_NO_MEM, err, TAG, "no mem for bundle");
|
ESP_GOTO_ON_FALSE(bundle, ESP_ERR_NO_MEM, err, TAG, "no mem for bundle");
|
||||||
|
|
||||||
// for performance reasons, we only search for continuous channels
|
// for performance reasons, we only search for continuous channels
|
||||||
|
Reference in New Issue
Block a user