-
-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add additional checks to Vector
class methods
#1721
Conversation
* SmingHub#1618 (comment) * Change `ensureCapacity` to adjust new capacity by `increment`, thus simplifying code which uses it * Add `bool` return value to: `addElement()` - so that `add()` return value isn't meaningless `ensureCapacity()` `setSize()` `insertElementAt()` `setElementAt()`
Sming/Wiring/WVector.h
Outdated
ensureCapacity(_capacity + _increment); | ||
if (_size < _capacity) | ||
_data[ _size++ ] = new Element(obj); | ||
if (!ensureCapacity(_size + 1)) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please at least put the return
on the next line with a bit of offset ? Best would be to use curly braces.
Apply those changes to the other places where you have a return on the same line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be simplest to just fix all the coding style issues in this file, i.e. just apply the Sming CS and fix all the style issues. The Arduino Esp8266 doesn't use this class (uses std:;vector instead) so it's really a Sming-only file ATM.
For example,causes exception when sorting network list in `HttpServer_ConfigNetwork` sample
For example,causes exception when sorting network list in `HttpServer_ConfigNetwork` sample
#1618 (comment)
ensureCapacity
to adjust new capacity byincrement
, thus simplifying code which uses itbool
return value to:addElement()
- so thatadd()
return value isn't meaninglessensureCapacity()
setSize()
insertElementAt()
setElementAt()