bigbigmdm / IMSProg

IMSProg - software for CH341A-based programmers to work with I2C, SPI and MicroWire EEPROM/Flash chips
https://antenna-dvb-t2.ru/IMSProg.php
GNU General Public License v3.0
215 stars 38 forks source link

memory leaks fixed #30

Closed VasiliyTurchenko closed 8 months ago

VasiliyTurchenko commented 8 months ago

Hi! I have noticed that a number of possible memory leaks may happen in the project. I fixed that, mostly using std::shared_ptr instead of raw pointers. It adds tiny overhead but automates memory deallocation at scope exit.

Also I have added

enum class chipType : uint8_t {chipTypeSPI = 0U,
                                   chipType25EE,
                                   chipType93EE,
                                   chipType24EE,
                                   chipType95EE};

instead of anonymous numbers to ease control flow management in the program.

VasiliyTurchenko commented 8 months ago
bigbigmdm commented 8 months ago

Hello! It's a good job! But you are not selecting the chip type correctly: 0- SPI (25xx) 1- i2c (24xx) 2- Microwire (93xx) 3- 25xxx is not used today (SPI but not NOR) 4- 95xxx Please split these changes into multiple pull requests. It will be easier for us to work that way.

The memory leak you fixed in dialogsfdp.cpp is also present in mainwindow.cpp.

VasiliyTurchenko commented 8 months ago

Oops.. I was mislead by this line:

QVector <QString> chType = {"SPI_FLASH","25_EEPROM","93_EEPROM","24_EEPROM","95_EEPROM"};

It seems that chType strings order is not the same as chipType numbers. Actually this QVector <QString> chType in mainwindow.h is unused and can be deleted.