Fix calloc allignment

This commit is contained in:
Theo Arends 2024-05-05 18:26:21 +02:00
parent 53073b374d
commit c41f18a9b6
5 changed files with 6 additions and 6 deletions

View File

@ -453,7 +453,7 @@ void setup(void) {
// Init settings and logging preparing for AddLog use // Init settings and logging preparing for AddLog use
#ifdef PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED #ifdef PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
ESP.setIramHeap(); ESP.setIramHeap();
Settings = (TSettings*)calloc(sizeof(TSettings), 1); // Allocate in "new" 16k heap space Settings = (TSettings*)calloc(1, sizeof(TSettings)); // Allocate in "new" 16k heap space
TasmotaGlobal.log_buffer = (char*)malloc(LOG_BUFFER_SIZE); // Allocate in "new" 16k heap space TasmotaGlobal.log_buffer = (char*)malloc(LOG_BUFFER_SIZE); // Allocate in "new" 16k heap space
ESP.resetHeap(); ESP.resetHeap();
if (TasmotaGlobal.log_buffer == nullptr) { if (TasmotaGlobal.log_buffer == nullptr) {
@ -464,7 +464,7 @@ void setup(void) {
} }
#endif // PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED #endif // PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
if (Settings == nullptr) { if (Settings == nullptr) {
Settings = (TSettings*)calloc(sizeof(TSettings), 1); Settings = (TSettings*)calloc(1, sizeof(TSettings));
} }
#ifdef ESP32 #ifdef ESP32

View File

@ -434,7 +434,7 @@ bool SettingsBufferAlloc(uint32_t upload_size) {
} }
if (!(settings_buffer = (uint8_t *)calloc(settings_size, 1))) { if (!(settings_buffer = (uint8_t *)calloc(1, settings_size))) {
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_UPLOAD_ERR_2)); // Not enough (memory) space AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_UPLOAD_ERR_2)); // Not enough (memory) space
return false; return false;
} }

View File

@ -1142,7 +1142,7 @@ void CmndMaxEnergyStart(void) {
/********************************************************************************************/ /********************************************************************************************/
void EnergyDrvInit(void) { void EnergyDrvInit(void) {
Energy = (tEnergy*)calloc(sizeof(tEnergy), 1); // Need calloc to reset registers to 0/false Energy = (tEnergy*)calloc(1, sizeof(tEnergy)); // Need calloc to reset registers to 0/false
if (!Energy) { return; } if (!Energy) { return; }
Energy->value = nullptr; Energy->value = nullptr;

View File

@ -1375,7 +1375,7 @@ void CmndMaxEnergyStart(void) {
/********************************************************************************************/ /********************************************************************************************/
void EnergyDrvInit(void) { void EnergyDrvInit(void) {
Energy = (tEnergy*)calloc(sizeof(tEnergy), 1); // Need calloc to reset registers to 0/false Energy = (tEnergy*)calloc(1, sizeof(tEnergy)); // Need calloc to reset registers to 0/false
if (!Energy) { return; } if (!Energy) { return; }
Energy->value = nullptr; Energy->value = nullptr;

View File

@ -529,7 +529,7 @@ void DomoticzSensorP1SmartMeter(char *usage1, char *usage2, char *return1, char
void DomoticzInit(void) { void DomoticzInit(void) {
if (Settings->flag.mqtt_enabled) { // SetOption3 - Enable MQTT if (Settings->flag.mqtt_enabled) { // SetOption3 - Enable MQTT
Domoticz = (Domoticz_t*)calloc(sizeof(Domoticz_t), 1); // Need calloc to reset registers to 0/false Domoticz = (Domoticz_t*)calloc(1, sizeof(Domoticz_t)); // Need calloc to reset registers to 0/false
if (nullptr == Domoticz) { return; } if (nullptr == Domoticz) { return; }
Domoticz->update_flag = true; Domoticz->update_flag = true;