Skip to content

Commit daa55d4

Browse files
committed
doc
1 parent 3eb2556 commit daa55d4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doc/reference.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ C++
239239

240240
Historically in Arduino environments, ``new`` is overloaded to simply return the equivalent ``malloc()`` which in turn can return ``nullptr``.
241241

242-
This behavior is not C++ standard, and there is good reason for that: there are hidden and very bad side effects. The *class and member constructors are always called, even when memory is full* (``this``=``nullptr``).
242+
This behavior is not C++ standard, and there is good reason for that: there are hidden and very bad side effects. The *class and member constructors are always called, even when memory is full* (``this == nullptr``).
243243
In addition, the memory allocation for the top object could succeed, but allocation required for some member object could fail, leaving construction in an undefined state.
244244
So the historical behavior of Ardudino's ``new``, when faced with insufficient memory, will lead to bad crashes sooner or later, sometimes unexplainable, generally due to memory corruption even when the returned value is checked and managed.
245245
Luckily on esp8266, trying to update RAM near address 0 will immediately raise an hardware exception, unlike on other uC like avr on which that memory can be accessible.
@@ -263,9 +263,9 @@ C++
263263

264264
- never calls constructors on oom
265265

266-
- returns nullptr (without side effects - excepted when parent constructors, or member constructors use ``new``)
266+
- returns nullptr on oom
267267

268-
It is similar to arduino ``new`` semantic without side effects.
268+
It is similar to arduino ``new`` semantic without side effects (excepted when parent constructors, or member constructors use ``new``)
269269

270270
Syntax is slightly different, the following shows the different usages:
271271

@@ -276,5 +276,5 @@ C++
276276
// with new:
277277
SomeClass* sc = new SomeClass(arg1, arg2, ...);
278278
279-
// with new0
279+
// with new0:
280280
SomeClass* sc = new0<SomeClass>(arg1, arg2, ...);

0 commit comments

Comments
 (0)