adafruit / adafruit/Adafruit_IO_Arduino
Strange mix of malloc and new
- Dominant language
- C++
- Stars
- 222
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating AdafruitIO_Group::_init and then search the repository for the malloc/free and new/delete patterns described in the issue. Review each affected allocation site and confirm that the resulting ownership and cleanup are consistent throughout the affected code; the issue provides no test file or named source file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- embedded-iot
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100