tmp/tmpo3sknel5/{from.md → to.md}
RENAMED
|
@@ -1,36 +1,46 @@
|
|
| 1 |
-
### C library <a id="c.malloc">[[c.malloc]]</a>
|
| 2 |
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
| 12 |
-
`::operator
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
unaffected by restrictions on pointers that are not safely derived, at
|
| 22 |
-
the expense of providing far fewer garbage collection and leak detection
|
| 23 |
-
options for `malloc()`-allocated objects. It also allows `malloc()` to
|
| 24 |
-
be implemented with a separate allocation arena, bypassing the normal
|
| 25 |
`declare_reachable()` implementation. The above functions should never
|
| 26 |
intentionally be used as a replacement for `declare_reachable()`, and
|
| 27 |
newly written code is strongly encouraged to treat memory allocated with
|
| 28 |
-
these functions as though it were allocated with
|
|
|
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
|
|
|
| 1 |
+
### C library memory allocation <a id="c.malloc">[[c.malloc]]</a>
|
| 2 |
|
| 3 |
+
[*Note 1*: The header `<cstdlib>` ([[cstdlib.syn]]) declares the
|
| 4 |
+
functions described in this subclause. — *end note*]
|
| 5 |
|
| 6 |
+
``` cpp
|
| 7 |
+
void* aligned_alloc(size_t alignment, size_t size);
|
| 8 |
+
void* calloc(size_t nmemb, size_t size);
|
| 9 |
+
void* malloc(size_t size);
|
| 10 |
+
void* realloc(void* ptr, size_t size);
|
| 11 |
+
```
|
| 12 |
|
| 13 |
+
*Effects:* These functions have the semantics specified in the C
|
| 14 |
+
standard library.
|
| 15 |
|
| 16 |
+
*Remarks:* These functions do not attempt to allocate storage by calling
|
| 17 |
+
`::operator new()` ([[support.dynamic]]).
|
| 18 |
|
| 19 |
+
Storage allocated directly with these functions is implicitly declared
|
| 20 |
+
reachable (see [[basic.stc.dynamic.safety]]) on allocation, ceases to
|
| 21 |
+
be declared reachable on deallocation, and need not cease to be declared
|
| 22 |
+
reachable as the result of an `undeclare_reachable()` call.
|
| 23 |
|
| 24 |
+
[*Note 1*: This allows existing C libraries to remain unaffected by
|
| 25 |
+
restrictions on pointers that are not safely derived, at the expense of
|
| 26 |
+
providing far fewer garbage collection and leak detection options for
|
| 27 |
+
`malloc()`-allocated objects. It also allows `malloc()` to be
|
| 28 |
+
implemented with a separate allocation arena, bypassing the normal
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
`declare_reachable()` implementation. The above functions should never
|
| 30 |
intentionally be used as a replacement for `declare_reachable()`, and
|
| 31 |
newly written code is strongly encouraged to treat memory allocated with
|
| 32 |
+
these functions as though it were allocated with
|
| 33 |
+
`operator new`. — *end note*]
|
| 34 |
|
| 35 |
+
``` cpp
|
| 36 |
+
void free(void* ptr);
|
| 37 |
+
```
|
| 38 |
|
| 39 |
+
*Effects:* This function has the semantics specified in the C standard
|
| 40 |
+
library.
|
| 41 |
|
| 42 |
+
*Remarks:* This function does not attempt to deallocate storage by
|
| 43 |
+
calling `::operator delete()`.
|
| 44 |
+
|
| 45 |
+
ISO C 7.22.3.
|
| 46 |
|