Skip to content

Commit d8949af

Browse files
author
mikeblome
committed
fixes per review
1 parent 20167b9 commit d8949af

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

docs/cpp/new-and-delete-operators.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ When a statement such as the following is encountered in a program, it translate
2121
char *pch = new char[BUFFER_SIZE];
2222
```
2323

24-
If the request is for zero bytes of storage, **operator new** returns a pointer to a distinct object (that is, repeated calls to **operator new** return different pointers). If there is insufficient memory for the allocation request, **operator new** throws a std::bad_alloc exception, or returns **nullptr** if you have linked in non-throwing **operator new** support.
24+
If the request is for zero bytes of storage, **operator new** returns a pointer to a distinct object (that is, repeated calls to **operator new** return different pointers). If there is insufficient memory for the allocation request, **operator new** throws a `std::bad_alloc` exception, or returns **nullptr** if you have linked in non-throwing **operator new** support.
2525

2626
You can write a routine that attempts to free memory and retry the allocation; see [_set_new_handler](../c-runtime-library/reference/set-new-handler.md) for more information. For more details on the recovery scheme, see the Handling insufficient memory section of this topic.
2727

@@ -97,7 +97,7 @@ int main()
9797

9898
### Handling insufficient memory
9999

100-
Testing for failed memory allocation can be done with code such as the following:
100+
Testing for failed memory allocation can be done as shown here:
101101

102102
```cpp
103103
#include <iostream>
@@ -112,7 +112,7 @@ int main() {
112112
}
113113
```
114114
115-
There is another ways to handle failed memory allocation requests: write a custom recovery routine to handle such a failure, then register your function by calling the [_set_new_handler](../c-runtime-library/reference/set-new-handler.md) run-time function.
115+
There is another way to handle failed memory allocation requests. Write a custom recovery routine to handle such a failure, then register your function by calling the [_set_new_handler](../c-runtime-library/reference/set-new-handler.md) run-time function.
116116
117117
## <a id="delete_operator"> </a> The delete operator
118118
@@ -129,7 +129,7 @@ void operator delete( void *, size_t );
129129

130130
Only one of the preceding two forms can be present for a given class. The first form takes a single argument of type `void *`, which contains a pointer to the object to deallocate. The second form—sized deallocation—takes two arguments, the first of which is a pointer to the memory block to deallocate and the second of which is the number of bytes to deallocate. The return type of both forms is **void** (**operator delete** cannot return a value).
131131

132-
The intent of the second form is to speed up searching for the correct size category of the object to be deleted, which is often not stored near the allocation itself and likely uncached; the second form is particularly useful when an **operator delete** function from a base class is used to delete an object of a derived class.
132+
The intent of the second form is to speed up searching for the correct size category of the object to be deleted, which is often not stored near the allocation itself and likely uncached. The second form is useful when an **operator delete** function from a base class is used to delete an object of a derived class.
133133

134134
The **operator delete** function is static; therefore, it cannot be virtual. The **operator delete** function obeys access control, as described in [Member-Access Control](member-access-control-cpp.md).
135135

docs/cpp/pointers-cpp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ ms.assetid: 595387c5-8e58-4670-848f-344c7caf985e
1010

1111
A pointer is a variable that stores the memory address of an object. Pointers are used extensively in both C and C++ for three main purposes:
1212

13-
1. to allocate new objects on the heap,
14-
1. to pass functions to other functions
15-
1. to iterate over elements in arrays or other data structures.
13+
- to allocate new objects on the heap,
14+
- to pass functions to other functions
15+
- to iterate over elements in arrays or other data structures.
1616

1717
In C-style programming, *raw pointers* are used for all these scenarios. However, raw pointers are the source of many serious programming errors. Therefore, their use is strongly discouraged except where they provide a significant performance benefit and there is no ambiguity as to which pointer is the *owning pointer* that is responsible for deleting the object. Modern C++ provides *smart pointers* for allocating objects, *iterators* for traversing data structures, and *lambda expressions* for passing functions. By using these language and library facilities instead of raw pointers, you will make your program safer, easier to debug, and simpler to understand and maintain. See [Smart pointers](smart-pointers-modern-cpp.md), [Iterators](../standard-library/iterators.md), and [Lambda expressions](lambda-expressions-in-cpp.md) for more information.
1818

@@ -27,7 +27,7 @@ In C-style programming, *raw pointers* are used for all these scenarios. However
2727
- [How to: Create and use weak_ptr instances](how-to-create-and-use-weak-ptr-instances.md)
2828
- [How to: Create and use CComPtr and CComQIPtr instances](how-to-create-and-use-ccomptr-and-ccomqiptr-instances.md)
2929

30-
## See Also
30+
## See also
3131

3232
[Iterators](../standard-library/iterators.md)</br>
3333
[Lambda expressions](lambda-expressions-in-cpp.md)

docs/cpp/raw-pointers.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: "Raw pointers (C++)"
3+
description: "How to use raw pointers in C++"
34
ms.date: "11/19/2019"
45
helpviewer_keywords: ["pointers [C++]"]
56
---

0 commit comments

Comments
 (0)