analogdevicesinc / Linduino

Code for the Linduino, An Arduino Uno-based board that is compatible with many Analog Devices evaluation boards
Other
99 stars 100 forks source link

In LTC681x.cpp don't use malloc/free #51

Open gudnimg opened 3 years ago

gudnimg commented 3 years ago

For example we change this:

uint8_t *cell_data = (uint8_t *) malloc((NUM_RX_BYT*TOTAL_IC)*sizeof(uint8_t));
// some code between ...
free(cell_data);

to this:

uint8_t cell_data[NUM_RX_BYT*TOTAL_IC];

When I change malloc/free everywhere in my version of LTC681x.cpp my program was 334 bytes smaller. (ATmega2560 and ATmega2561). For this use case we shouldn't really be using malloc/free if it is not a must.

gudnimg commented 3 years ago

I noticed also that there is one instance of malloc in LTC6810_rds() in LTC6810.cpp.