You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/c-runtime-library/delete-operator-crt.md
+1-47Lines changed: 1 addition & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,50 +45,4 @@ translation.priority.ht:
45
45
- "zh-tw"
46
46
---
47
47
# operator delete(CRT)
48
-
Frees allocated block.
49
-
50
-
## Syntax
51
-
52
-
```
53
-
54
-
void __cdecl operator delete[](void * object);
55
-
void __cdecl operator delete[](void * object,
56
-
void * memory) throw();
57
-
void __cdecl operator delete[](void * object,
58
-
const std::nothrow_t&) throw();
59
-
```
60
-
61
-
#### Parameters
62
-
*memory*
63
-
The memory location being freed.
64
-
65
-
*object*
66
-
A pointer to the object being deleted.
67
-
68
-
## Remarks
69
-
This form of **operator delete** is known as vector delete, in contrast to the scalar delete form ([operator delete](../c-runtime-library/operator-delete-crt.md)).
70
-
71
-
**operator**`delete[]` frees memory allocated by [operator new[]](../c-runtime-library/new-operator-crt.md).
72
-
73
-
The first form of this operator is known as the nonplacement form. The second and third forms of this operator will commonly not be called from code but exist to give the compiler a matching delete to call when a placement new fails.
74
-
75
-
The first form of the operator is defined by the compiler and does not require new.h to be included in your program.
76
-
77
-
With the exception of throwing or no-throwing behavior, the CRT **operator**`delete[]` behaves like [operator delete[]](../Topic/operator%20delete\(%3Cnew%3E\).md) in the Standard C++ Library.
78
-
79
-
## Requirements
80
-
81
-
|Routine|Required header|
82
-
|-------------|---------------------|
83
-
|`delete[]`|\<new.h>|
84
-
85
-
For additional compatibility information, see [Compatibility](../c-runtime-library/compatibility.md) in the Introduction.
86
-
87
-
## Libraries
88
-
All versions of the [C run-time libraries](../c-runtime-library/crt-library-features.md).
89
-
90
-
## Example
91
-
See [operator new[]](../c-runtime-library/new-operator-crt.md) for examples of using operator **delete**.
Beginning in Visual Studio 2013, the Universal C Runtime (UCRT) no longer supports the C++-specific operator new and operator delete functions. These are now part of the C++ Standard Library. For more information, see [new and delete operators](../../cpp/new-and-delete-operators.md) and [delete operator](../../cpp/delete-operator-cpp.md) in the C++ Language Reference.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/new-operator-crt.md
+1-100Lines changed: 1 addition & 100 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,103 +45,4 @@ translation.priority.ht:
45
45
- "zh-tw"
46
46
---
47
47
# operator new(CRT)
48
-
Allocate block of memory from heap
49
-
50
-
## Syntax
51
-
52
-
```
53
-
54
-
void *__cdecl operator new[](size_t count);
55
-
void *__cdecl operator new[] (
56
-
size_t count,
57
-
void * object
58
-
) throw();
59
-
void *__cdecl operator new[] (
60
-
size_t count,
61
-
const std::nothrow_t&
62
-
) throw();
63
-
```
64
-
65
-
#### Parameters
66
-
*count*
67
-
The size of the allocation.
68
-
69
-
*object*
70
-
A pointer to a block of memory in which the object will be created.
71
-
72
-
## Return Value
73
-
A pointer to the lowest byte address of the newly allocated storage.
74
-
75
-
## Remarks
76
-
This form of `operator new` is known as vector new, in contrast to the scalar new form ([operator new](../c-runtime-library/operator-new-crt.md)).
77
-
78
-
The first form of this operator is known as the nonplacement form. The second form of this operator is known as the placement form and the third form of this operator is the nonthrowing placement form.
79
-
80
-
The first form of the operator is defined by the compiler and does not require new.h to be included in your program.
81
-
82
-
[operator delete[]](../Topic/operator%20delete\(%3Cnew%3E\).md) frees memory allocated with operator new.
83
-
84
-
You can configure whether `operator new[]` returns null or throws an exception on failure. See [The new and delete Operators](../cpp/new-and-delete-operators.md) for more information.
85
-
86
-
With the exception of throwing or no-throwing behavior, the CRT `operator new` behaves like [operator new[]](../Topic/operator%20new\(%3Cnew%3E\).md) in the Standard C++ Library.
87
-
88
-
## Requirements
89
-
90
-
|Routine|Required header|
91
-
|-------------|---------------------|
92
-
|`new[]`|\<new.h>|
93
-
94
-
For additional compatibility information, see [Compatibility](../c-runtime-library/compatibility.md) in the Introduction.
95
-
96
-
## Libraries
97
-
All versions of the [C run-time libraries](../c-runtime-library/crt-library-features.md).
98
-
99
-
## Example
100
-
The following shows how to use the vector, nonplacement form of `operator new`.
101
-
102
-
```
103
-
// crt_new4.cpp
104
-
#include <stdio.h>
105
-
int main() {
106
-
int * k = new int[10];
107
-
k[0] = 21;
108
-
printf("%d\n", k[0]);
109
-
delete [] k;
110
-
}
111
-
```
112
-
113
-
The following shows how to use the vector, placement form of `operator new`.
114
-
115
-
```
116
-
// crt_new5.cpp
117
-
#include <stdio.h>
118
-
#include <new.h>
119
-
int main() {
120
-
int * i = new int[10];
121
-
i[0] = 21;
122
-
printf("%d\n", i[0]);
123
-
// initialize existing memory (i) with, in this case, int[[10]
124
-
int * j = new(i) int[10]; // placement vector new
125
-
printf("%d\n", j[0]);
126
-
j[0] = 22;
127
-
printf("%d\n", i[0]);
128
-
delete [] i; // or, could have deleted [] j
129
-
}
130
-
```
131
-
132
-
The following shows how to use the vector, placement, no-throw form of `operator new`.
Beginning in Visual Studio 2013, the Universal C Runtime (UCRT) no longer supports the C++-specific operator new and operator delete functions. These are now part of the C++ Standard Library. For more information, see [new and delete operators](../../cpp/new-and-delete-operators.md) and [new operator](../../cpp/new-operator-cpp.md) in the C++ Language Reference.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/operator-delete-crt.md
+1-53Lines changed: 1 addition & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,56 +45,4 @@ translation.priority.ht:
45
45
- "zh-tw"
46
46
---
47
47
# operator delete (CRT)
48
-
Frees allocated block.
49
-
50
-
## Syntax
51
-
52
-
```
53
-
54
-
void __cdecl operator delete(
55
-
void * object
56
-
);
57
-
void __cdecl operator delete(
58
-
void * object,
59
-
void * memory
60
-
) throw();
61
-
void __cdecl operator delete(
62
-
void * object,
63
-
const std::nothrow_t&
64
-
) throw();
65
-
```
66
-
67
-
#### Parameters
68
-
*memory*
69
-
The memory location being freed.
70
-
71
-
*object*
72
-
A pointer to the object being deleted.
73
-
74
-
## Remarks
75
-
This form of **operator delete** is known as scalar delete, in contrast to the vector delete form ([operator delete[]](../c-runtime-library/delete-operator-crt.md)).
76
-
77
-
**operator delete** frees memory allocated by [operator new](../c-runtime-library/operator-new-crt.md).
78
-
79
-
The first form of this operator is known as the nonplacement form. The second and third forms of this operator will commonly not be called from code but exist to give the compiler a matching delete to call when a placement new fails.
80
-
81
-
The first form of the operator is defined by the compiler and does not require new.h to be included in your program.
82
-
83
-
With the exception of throwing or no-throwing behavior, the CRT **operator delete** behaves like [operator delete](../Topic/operator%20delete%20\(%3Cnew%3E\).md) in the Standard C++ Library.
84
-
85
-
## Requirements
86
-
87
-
|Routine|Required header|
88
-
|-------------|---------------------|
89
-
|**delete**|\<new.h>|
90
-
91
-
For additional compatibility information, see [Compatibility](../c-runtime-library/compatibility.md) in the Introduction.
92
-
93
-
## Libraries
94
-
All versions of the [C run-time libraries](../c-runtime-library/crt-library-features.md).
95
-
96
-
## Example
97
-
See [operator new](../c-runtime-library/operator-new-crt.md) for examples of using operator **delete**.
Beginning in Visual Studio 2013, the Universal C Runtime (UCRT) no longer supports the C++-specific operator new and operator delete functions. These are now part of the C++ Standard Library. For more information, see [new and delete operators](../../cpp/new-and-delete-operators.md) and [delete operator](../../cpp/delete-operator-cpp.md) in the C++ Language Reference.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/operator-new-crt.md
+1-102Lines changed: 1 addition & 102 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,105 +43,4 @@ translation.priority.ht:
43
43
- "zh-tw"
44
44
---
45
45
# operator new (CRT)
46
-
Allocates block of memory from heap
47
-
48
-
## Syntax
49
-
50
-
```
51
-
52
-
void *__cdecl operator new(
53
-
size_t count
54
-
);
55
-
void *__cdecl operator new(
56
-
size_t count,
57
-
void * object
58
-
) throw();
59
-
void *__cdecl operator new(
60
-
size_t count,
61
-
const std::nothrow_t&
62
-
) throw();
63
-
```
64
-
65
-
#### Parameters
66
-
*count*
67
-
The size of the allocation.
68
-
69
-
*object*
70
-
A pointer to a block of memory in which the object will be created.
71
-
72
-
## Return Value
73
-
A pointer to the lowest byte address of the newly allocated storage.
74
-
75
-
## Remarks
76
-
This form of `operator new` is known as scalar new, in contrast to the vector new form ([operator new[]](../c-runtime-library/new-operator-crt.md)).
77
-
78
-
The first form of this operator is known as the nonplacement form. The second form of this operator is known as the placement form and the third form of this operator is the nonthrowing, placement form.
79
-
80
-
The first form of the operator is defined by the compiler and does not require new.h to be included in your program.
81
-
82
-
[operator delete](../c-runtime-library/operator-delete-crt.md) frees memory allocated with `operator new`.
83
-
84
-
You can configure whether operator new returns null or throws an exception on failure. See [The new and delete Operators](../cpp/new-and-delete-operators.md) for more information.
85
-
86
-
With the exception of throwing or no-throwing behavior, the CRT `operator new` behaves like [operator new](../Topic/operator%20new%20\(%3Cnew%3E\).md) in the Standard C++ Library.
87
-
88
-
## Requirements
89
-
90
-
|Routine|Required header|
91
-
|-------------|---------------------|
92
-
|**new**|\<new.h>|
93
-
94
-
For additional compatibility information, see [Compatibility](../c-runtime-library/compatibility.md) in the Introduction.
95
-
96
-
## Libraries
97
-
All versions of the [C run-time libraries](../c-runtime-library/crt-library-features.md).
98
-
99
-
## Example
100
-
The following shows how to use the scalar, nonplacement form of `operator new`.
101
-
102
-
```
103
-
// crt_new1.cpp
104
-
#include <stdio.h>
105
-
int main() {
106
-
int * i = new int(6);
107
-
printf("%d\n", *i);
108
-
delete i;
109
-
}
110
-
```
111
-
112
-
The following shows how to use the scalar, placement form of `operator new`.
113
-
114
-
```
115
-
// crt_new2.cpp
116
-
#include <stdio.h>
117
-
#include <new.h>
118
-
int main() {
119
-
int * i = new int(12);
120
-
printf("*i = %d\n", *i);
121
-
// initialize existing memory (i) with, in this case, int(7)
122
-
int * j = new(i) int(7); // placement new
123
-
printf("*j = %d\n", *j);
124
-
printf("*i = %d\n", *i);
125
-
delete i; // or, could have deleted j
126
-
}
127
-
```
128
-
129
-
The following shows how to use the scalar, placement, no-throw form of `operator new`.
130
-
131
-
```
132
-
// crt_new3.cpp
133
-
#include <stdio.h>
134
-
#include <new.h>
135
-
int main() {
136
-
// allocates memory, initialize (8) and if call fails, new returns null
137
-
int * k = new(std::nothrow) int(8); // placement new
138
-
printf("%d\n", *k);
139
-
delete k;
140
-
}
141
-
```
142
-
143
-
## .NET Framework Equivalent
144
-
Not applicable. To call the standard C function, use `PInvoke`. For more information, see [Platform Invoke Examples](http://msdn.microsoft.com/Library/15926806-f0b7-487e-93a6-4e9367ec689f).
Beginning in Visual Studio 2013, the Universal C Runtime (UCRT) no longer supports the C++-specific operator new and operator delete functions. These are now part of the C++ Standard Library. For more information, see [new and delete operators](../../cpp/new-and-delete-operators.md) and [new operator](../../cpp/new-operator-cpp.md) in the C++ Language Reference.
Not applicable. To call the standard C function, use `PInvoke`. For more information, see [Platform Invoke Examples](http://msdn.microsoft.com/Library/15926806-f0b7-487e-93a6-4e9367ec689f).
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/query-new-handler.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,8 +60,7 @@ Returns the address of the current new handler routine.
60
60
## Syntax
61
61
62
62
```
63
-
64
-
_PNH _query_new_handler(
63
+
_PNH _query_new_handler(
65
64
void
66
65
);
67
66
```
@@ -70,7 +69,7 @@ Returns the address of the current new handler routine.
70
69
Returns the address of the current new handler routine as set by `_set_new_handler`.
71
70
72
71
## Remarks
73
-
The C++ `_query_new_handler` function returns the address of the current exception-handling function set by the C++ [_set_new_handler](../../c-runtime-library/reference/set-new-handler.md) function. `_set_new_handler` is used to specify an exception-handling function that is to gain control if the **new** operator fails to allocate memory. For more information, see the discussions of the [operator new](../../misc/operator-new-function.md) and [operator delete](../../misc/operator-delete-function.md)functions in *C++ Language Reference*.
72
+
The C++ `_query_new_handler` function returns the address of the current exception-handling function set by the C++ [_set_new_handler](../../c-runtime-library/reference/set-new-handler.md) function. `_set_new_handler` is used to specify an exception-handling function that is to gain control if the **new** operator fails to allocate memory. For more information, see the discussion of the [new and delete operators](../../cpp/new-and-delete-operators.md) in the C++ Language Reference.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/query-new-mode.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,7 @@ Returns an integer indicating the new handler mode set by `_set_new_mode` for `m
69
69
Returns the current new handler mode, namely 0 or 1, for `malloc`. A return value of 1 indicates that, on failure to allocate memory, `malloc` calls the new handler routine; a return value of 0 indicates that it does not.
70
70
71
71
## Remarks
72
-
The C++ `_query_new_mode` function returns an integer that indicates the new handler mode that is set by the C++ [_set_new_mode](../../c-runtime-library/reference/set-new-mode.md) function for [malloc](../../c-runtime-library/reference/malloc.md). The new handler mode indicates whether, on failure to allocate memory, `malloc` is to call the new handler routine as set by [_set_new_handler](../../c-runtime-library/reference/set-new-handler.md). By default, `malloc` does not call the new handler routine on failure. You can use `_set_new_mode` to override this behavior so that on failure `malloc` calls the new handler routine in the same way that the **new** operator does when it fails to allocate memory. For more information, see the [operator delete](../../misc/operator-delete-function.md) and [operator new](../../misc/operator-new-function.md)functions in *C++ Language Reference*.
72
+
The C++ `_query_new_mode` function returns an integer that indicates the new handler mode that is set by the C++ [_set_new_mode](../../c-runtime-library/reference/set-new-mode.md) function for [malloc](../../c-runtime-library/reference/malloc.md). The new handler mode indicates whether, on failure to allocate memory, `malloc` is to call the new handler routine as set by [_set_new_handler](../../c-runtime-library/reference/set-new-handler.md). By default, `malloc` does not call the new handler routine on failure. You can use `_set_new_mode` to override this behavior so that on failure `malloc` calls the new handler routine in the same way that the **new** operator does when it fails to allocate memory. For more information, see the discussion of the [new and delete operators](../../cpp/new-and-delete-operators.md) in the C++ Language Reference.
0 commit comments