arduino / arduino/ArduinoCore-renesas

(WifiS3 WiFiClient) Reduce memory allocations

Open
#407 2 comments 0 reactions 0 assignees View on GitHub
topic: code type: enhancement type: imperfection
Dominant language
C
Stars
193
Forks
112
PR merge metrics
No merged PRs in 30d

Description

Embedded devices should avoid to use memory allocation - or limit allocations to minimum. Unfortunately, the code for WiFi does not honour this rule.

- don't use std::string, use static allocated buffer
- don't use std::make_shared - we have C++17, implementing copy constructors for every class is no longer required. WiFiClient can have preallocated buffer as member variable. The programmer can possibly choose to use std::make_shared for the whole WiFIClient instance, if it needs to share it by other objects.
- typo: destroy_at_distructor
- bug: the flag destroy_at_distructor is never used, destructor is empty.

https://github.com/arduino/ArduinoCore-renesas/blob/03b4a91db49dae7601701c33cd09924ea6b363d3/libraries/WiFiS3/src/WiFiClient.cpp#L6

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with libraries/WiFiS3/src/WiFiClient.cpp at the linked allocation code. Review how WiFiClient currently uses std::string, std::make_shared, and the destroy_at_distructor flag. Done means reducing avoidable allocations, correcting the typo, and making the destruction flag meaningful rather than leaving the destructor empty.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.