WillNilges / octo-dash-curses

A simple dashboard for displaying the status of octoprint servers on the CLI
MIT License
3 stars 0 forks source link

Implement cJSON and re-do CURL request structure #25

Closed WillNilges closed 3 years ago

WillNilges commented 3 years ago

This should solve most of our memory problems.

This PR rips JSMN out of the project and replaces it with cJSON. As such, it re-does basically all of the JSON parsing.

Strings are re-designed as well, as is the structure of CURL requests to the OctoPrint server. Hopefully all of this will culminate into a reliable piece of software.

A few minor tweaks also include using q to quit cleanly, and the refresh rate being displayed on the UI.

Closes #3 #8 (and maybe #9).


valgrind --tool=memcheck --leak-check=full --track-origins=yes  ./odc
==356433== Memcheck, a memory error detector
==356433== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==356433== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==356433== Command: ./odc
==356433==
==356433==
==356433== HEAP SUMMARY:
==356433==     in use at exit: 569,481 bytes in 226 blocks
==356433==   total heap usage: 73,301 allocs, 73,075 frees, 18,529,019 bytes allocated
==356433==
==356433== 363 bytes in 1 blocks are definitely lost in loss record 23 of 48
==356433==    at 0x483BCE8: realloc (vg_replace_malloc.c:834)
==356433==    by 0x403777: writefunc (api.c:8)
==356433==    by 0x48B6E2A: ??? (in /usr/lib64/libcurl.so.4.6.0)
==356433==    by 0x48C5EAA: ??? (in /usr/lib64/libcurl.so.4.6.0)
==356433==    by 0x48AD496: ??? (in /usr/lib64/libcurl.so.4.6.0)
==356433==    by 0x48AE689: curl_multi_perform (in /usr/lib64/libcurl.so.4.6.0)
==356433==    by 0x48847B2: curl_easy_perform (in /usr/lib64/libcurl.so.4.6.0)
==356433==    by 0x40395E: octoprint_comm_recv (api.c:49)
==356433==    by 0x4027BC: main (main.c:101)
==356433==
==356433== LEAK SUMMARY:
==356433==    definitely lost: 363 bytes in 1 blocks
==356433==    indirectly lost: 0 bytes in 0 blocks
==356433==      possibly lost: 0 bytes in 0 blocks
==356433==    still reachable: 569,118 bytes in 225 blocks
==356433==         suppressed: 0 bytes in 0 blocks
==356433== Reachable blocks (those to which a pointer was found) are not shown.
==356433== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==356433==
==356433== For lists of detected and suppressed errors, rerun with: -s
==356433== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)```
WillNilges commented 3 years ago

I'm gonna merge this. It's been running for months and has been doing really well.