https://github.com/espressif/esp-idf/bl ... m_nimble.c
Code: Select all
gatt_svr_dsc_access(uint16_t conn_handle, uint16_t attr_handle, struct
ble_gatt_access_ctxt *ctxt, void *arg)
{
if (ctxt->op != BLE_GATT_ACCESS_OP_READ_DSC) {
ESP_LOGE(TAG, "Invalid operation on Read-only Descriptor");
return BLE_ATT_ERR_UNLIKELY;
}
int rc;
char *temp_outbuf = strdup(ctxt->dsc->arg);
if (temp_outbuf == NULL) {
ESP_LOGE(TAG, "Error duplicating user description of characteristic");
return BLE_ATT_ERR_INSUFFICIENT_RES;
}
ssize_t temp_outlen = strlen(temp_outbuf);
rc = os_mbuf_append(ctxt->om, temp_outbuf, temp_outlen);
free(temp_outbuf);
return rc;
}
Dynamic allocations are banned by many embedded development standards. Other embedded libraries usually provide some custom malloc replacement, like fixed block heaps, etc, but ESP-IDF looks like it is written for a desktop GUI or Web server space, not an embedded market.