diff --git a/src/main.cpp b/src/main.cpp index c32c1a1..a741521 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,10 +5,6 @@ #include "stock.h" #include "wifi.h" -//#include "esp_heap_trace.h" - -//static heap_trace_record_t trace_record[200]; - esp_err_t init_nvs() { esp_err_t ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { @@ -28,7 +24,6 @@ void init() { extern "C" void app_main() { // TODO: Get internet with GUEST_WLAN - // TODO: Memory leak const char* TAG = "app_main"; @@ -42,18 +37,9 @@ extern "C" void app_main() { xTaskCreate(fetch_stock_task, "fetch_stock_task", 1024*4, NULL, configMAX_PRIORITIES-1, NULL); /* - ESP_ERROR_CHECK(heap_trace_init_standalone(trace_record, 200)); - ESP_ERROR_CHECK(heap_trace_start(HEAP_TRACE_LEAKS)); - - int i = 1; for(;;) { ESP_LOGI("mem", "Free heap=%lu", esp_get_free_heap_size()); vTaskDelay(60000 / portTICK_PERIOD_MS); - if(--i == 0) { - ESP_ERROR_CHECK(heap_trace_stop()); - heap_trace_dump(); - } - } */ diff --git a/src/stock.cpp b/src/stock.cpp index c757024..547d120 100644 --- a/src/stock.cpp +++ b/src/stock.cpp @@ -84,15 +84,18 @@ esp_err_t parse_JSON(const char* json, float* current, float* delta) { if (cJSON_GetObjectItem(root, "c")) { *current = (float)cJSON_GetObjectItem(root,"c")->valuedouble; } else { + cJSON_Delete(root); return ESP_ERR_NOT_FOUND; } if (cJSON_GetObjectItem(root, "d")) { *delta = (float)cJSON_GetObjectItem(root,"d")->valuedouble; } else { + cJSON_Delete(root); return ESP_ERR_NOT_FOUND; } + cJSON_Delete(root); return ESP_OK; }