adafruit / Adafruit_IO_Arduino

Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.
Other
209 stars 108 forks source link

Strange mix of malloc and new #50

Open supuflounder opened 6 years ago

supuflounder commented 6 years ago

While this is not an actual error, it does not represent Best Practice in C++ programming. In a number of places, such as in AdafruitIO_Group::_init, both malloc and new are used. The use of bare malloc in C++ is frowned upon. It is normally hidden inside the new operator. What is odd is that the computations are of the form var = (char *)malloc(e); for e being some expression. In C++, this can (and should) be written as var = new char[e]; and therefore the odd mix of malloc/free and new/delete can be avoided.