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
Compares two memory states and returns their differences (debug version only).
16
15
@@ -26,36 +25,36 @@ int _CrtMemDifference(
26
25
27
26
### Parameters
28
27
29
-
*stateDiff*\
30
-
Pointer to a **_CrtMemState** structure that is used to store the differences between the two memory states (returned).
28
+
*`stateDiff`*\
29
+
Pointer to a **`_CrtMemState`** structure that is used to store the differences between the two memory states (returned).
31
30
32
-
*oldState*\
33
-
Pointer to an earlier memory state (**_CrtMemState** structure).
31
+
*`oldState`*\
32
+
Pointer to an earlier memory state (**`_CrtMemState`** structure).
34
33
35
-
*newState*\
36
-
Pointer to a later memory state (**_CrtMemState** structure).
34
+
*`newState`*\
35
+
Pointer to a later memory state (**`_CrtMemState`** structure).
37
36
38
37
## Return Value
39
38
40
-
If the memory states are significantly different, **_CrtMemDifference** returns TRUE. Otherwise, the function returns FALSE.
39
+
If the memory states are significantly different, **`_CrtMemDifference`** returns `TRUE`. Otherwise, the function returns FALSE.
41
40
42
41
## Remarks
43
42
44
-
The **_CrtMemDifference** function compares *oldState* and *newState* and stores their differences in *stateDiff*, which can then be used by the application to detect memory leaks and other memory problems. When [_DEBUG](../../c-runtime-library/debug.md)is not defined, calls to **_CrtMemDifference** are removed during preprocessing.
43
+
The **`_CrtMemDifference`** function compares *`oldState`* and *`newState`* and stores their differences in *`stateDiff`*, which can then be used by the app to detect memory leaks and other memory problems. When [_DEBUG](../../c-runtime-library/debug.md)isn't defined, calls to **`_CrtMemDifference`** are removed during preprocessing.
45
44
46
-
*newState* and *oldState* must each be a valid pointer to a **_CrtMemState** structure, defined in Crtdbg.h, that has been filled in by [_CrtMemCheckpoint](crtmemcheckpoint.md) before calling **_CrtMemDifference**. *stateDiff* must be a pointer to a previously allocated instance of the **_CrtMemState** structure. If *stateDiff*, *newState*, or *oldState* is **NULL**, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, [errno, _doserrno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md) is set to **EINVAL** and the function returns FALSE.
45
+
*`newState`* and *`oldState`* must each be a valid pointer to a **`_CrtMemState`** structure, defined in Crtdbg.h, that has been filled in by [`_CrtMemCheckpoint`](crtmemcheckpoint.md) before calling **`_CrtMemDifference`**. *`stateDiff`* must be a pointer to a previously allocated instance of the **`_CrtMemState`** structure. If *`stateDiff`*, *`newState`*, or *`oldState`* is **`NULL`**, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, [`errno, _doserrno, _sys_errlist, and _sys_nerr`](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md) is set to **`EINVAL`** and the function returns FALSE.
47
46
48
-
**_CrtMemDifference** compares the **_CrtMemState** field values of the blocks in *oldState* to those in *newState* and stores the result in *stateDiff*. When the number of allocated block types or total number of allocated blocks for each type differs between the two memory states, the states are said to be significantly different. The difference between the largest amount ever allocated at once for the two states and the difference between total allocations for the two states are also stored in *stateDiff*.
47
+
**`_CrtMemDifference`** compares the **`_CrtMemState`** field values of the blocks in *`oldState`* to those in *`newState`* and stores the result in *`stateDiff`*. When the number of allocated block types or total number of allocated blocks for each type differs between the two memory states, the states are said to be significantly different. The difference between the largest amount ever allocated at once for the two states and the difference between total allocations for the two states are also stored in *`stateDiff`*.
49
48
50
-
By default, internal C run-time blocks (**_CRT_BLOCK**) are not included in memory state operations. The [_CrtSetDbgFlag](crtsetdbgflag.md) function can be used to turn on the **_CRTDBG_CHECK_CRT_DF** bit of **_crtDbgFlag** to include these blocks in leak detection and other memory state operations. Freed memory blocks (**_FREE_BLOCK**) do not cause **_CrtMemDifference** to return TRUE.
49
+
By default, internal C run-time blocks (**`_CRT_BLOCK`**) aren't included in memory state operations. The [_CrtSetDbgFlag](crtsetdbgflag.md) function can be used to turn on the **`_CRTDBG_CHECK_CRT_DF`** bit of **`_crtDbgFlag`** to include these blocks in leak detection and other memory state operations. Freed memory blocks (**`_FREE_BLOCK`**) don't cause **`_CrtMemDifference`** to return `TRUE`.
51
50
52
-
For more information about heap state functions and the **_CrtMemState** structure, see [Heap State Reporting Functions](/visualstudio/debugger/crt-debug-heap-details). For information about how memory blocks are allocated, initialized, and managed in the debug version of the base heap, see [CRT Debug Heap Details](/visualstudio/debugger/crt-debug-heap-details).
51
+
For more information about heap state functions and the **`_CrtMemState`** structure, see [Heap State Reporting Functions](/visualstudio/debugger/crt-debug-heap-details). For information about how memory blocks are allocated, initialized, and managed in the debug version of the base heap, see [CRT Debug Heap Details](/visualstudio/debugger/crt-debug-heap-details).
Specifies the destination or destinations for a specific report type generated by **_CrtDbgReport** and any macros that call [_CrtDbgReport, _CrtDbgReportW](crtdbgreport-crtdbgreportw.md), such as [_ASSERT, _ASSERTE, _ASSERT_EXPR Macros](assert-asserte-assert-expr-macros.md), [_ASSERT, _ASSERTE, _ASSERT_EXPR Macros](assert-asserte-assert-expr-macros.md), [_RPT, _RPTF, _RPTW, _RPTFW Macros](rpt-rptf-rptw-rptfw-macros.md), and [_RPT, _RPTF, _RPTW, _RPTFW Macros](rpt-rptf-rptw-rptfw-macros.md) (debug version only).
14
+
Specifies the destination or destinations for a specific report type generated by **_CrtDbgReport** and any macros that call [`_CrtDbgReport, _CrtDbgReportW`](crtdbgreport-crtdbgreportw.md), such as [`_ASSERT, _ASSERTE, _ASSERT_EXPR` Macros](assert-asserte-assert-expr-macros.md), [`_ASSERT, _ASSERTE, _ASSERT_EXPR` Macros](assert-asserte-assert-expr-macros.md), [`_RPT, _RPTF, _RPTW, _RPTFW` Macros](rpt-rptf-rptw-rptfw-macros.md), and [`_RPT, _RPTF, _RPTW, _RPTFW` Macros](rpt-rptf-rptw-rptfw-macros.md) (debug version only).
16
15
17
16
## Syntax
18
17
@@ -25,66 +24,66 @@ int _CrtSetReportMode(
25
24
26
25
### Parameters
27
26
28
-
*reportType*<br/>
29
-
Report type: **_CRT_WARN**, **_CRT_ERROR**, and **_CRT_ASSERT**.
27
+
*`reportType`*\
28
+
Report type: **`_CRT_WARN`**, **`_CRT_ERROR`**, and **`_CRT_ASSERT`**.
30
29
31
-
*reportMode*<br/>
32
-
New report mode or modes for *reportType*.
30
+
*`reportMode`*\
31
+
New report mode or modes for *`reportType`*.
33
32
34
33
## Return Value
35
34
36
-
On successful completion, **_CrtSetReportMode** returns the previous report mode or modes for the report type specified in *reportType*. If an invalid value is passed in as *reportType* or an invalid mode is specified for *reportMode*, **_CrtSetReportMode** invokes the invalid parameter handler as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, this function sets **errno** to **EINVAL** and returns -1. For more information, see [errno, _doserrno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
35
+
On successful completion, **`_CrtSetReportMode`** returns the previous report mode or modes for the report type specified in *`reportType`*. If an invalid value is passed in as *`reportType`* or an invalid mode is specified for *`reportMode`*, **`_CrtSetReportMode`** invokes the invalid parameter handler as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, this function sets **`errno`** to **`EINVAL`** and returns -1. For more information, see [`errno, _doserrno, _sys_errlist, and _sys_nerr`](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
37
36
38
37
## Remarks
39
38
40
-
**_CrtSetReportMode** specifies the output destination for **_CrtDbgReport**. Because the macros [_ASSERT](assert-asserte-assert-expr-macros.md), [_ASSERTE](assert-asserte-assert-expr-macros.md), [_RPT](rpt-rptf-rptw-rptfw-macros.md), and [_RPTF](rpt-rptf-rptw-rptfw-macros.md) call **_CrtDbgReport**, **_CrtSetReportMode** specifies the output destination of text specified with those macros.
39
+
**`_CrtSetReportMode`** specifies the output destination for **`_CrtDbgReport`**. Because the macros [`_ASSERT`](assert-asserte-assert-expr-macros.md), [`_ASSERTE`](assert-asserte-assert-expr-macros.md), [`_RPT`](rpt-rptf-rptw-rptfw-macros.md), and [`_RPTF`](rpt-rptf-rptw-rptfw-macros.md) call **`_CrtDbgReport`**, **`_CrtSetReportMode`** specifies the output destination of text specified with those macros.
41
40
42
-
When [_DEBUG](../../c-runtime-library/debug.md) is not defined, calls to **_CrtSetReportMode** are removed during preprocessing.
41
+
When [`_DEBUG`](../../c-runtime-library/debug.md) is not defined, calls to **`_CrtSetReportMode`** are removed during preprocessing.
43
42
44
-
If you do not call **_CrtSetReportMode** to define the output destination of messages, then the following defaults are in effect:
43
+
If you do not call **`_CrtSetReportMode`** to define the output destination of messages, then the following defaults are in effect:
45
44
46
45
- Assertion failures and errors are directed to a debug message window.
47
46
48
47
- Warnings from Windows applications are sent to the debugger's output window.
49
48
50
49
- Warnings from console applications are not displayed.
51
50
52
-
The following table lists the report types defined in Crtdbg.h.
51
+
The following table lists the report types defined in `Crtdbg.h`.
53
52
54
53
|Report type|Description|
55
54
|-----------------|-----------------|
56
-
|**_CRT_WARN**|Warnings, messages, and information that does not need immediate attention.|
57
-
|**_CRT_ERROR**|Errors, unrecoverable problems, and issues that require immediate attention.|
58
-
|**_CRT_ASSERT**|Assertion failures (asserted expressions that evaluate to **FALSE**).|
55
+
|**`_CRT_WARN`**|Warnings, messages, and information that does not need immediate attention.|
56
+
|**`_CRT_ERROR`**|Errors, unrecoverable problems, and issues that require immediate attention.|
57
+
|**`_CRT_ASSERT`**|Assertion failures (asserted expressions that evaluate to **`FALSE`**).|
59
58
60
-
The **_CrtSetReportMode** function assigns the new report mode specified in *reportMode* to the report type specified in *reportType* and returns the previously defined report mode for *reportType*. The following table lists the available choices for *reportMode* and the resulting behavior of **_CrtDbgReport**. These options are defined as bit flags in Crtdbg.h.
59
+
The **`_CrtSetReportMode`** function assigns the new report mode specified in *`reportMode`* to the report type specified in *`reportType`* and returns the previously defined report mode for *`reportType`*. The following table lists the available choices for *`reportMode`* and the resulting behavior of **`_CrtDbgReport`**. These options are defined as bit flags in Crtdbg.h.
61
60
62
61
|Report mode|_CrtDbgReport behavior|
63
62
|-----------------|-----------------------------|
64
-
|**_CRTDBG_MODE_DEBUG**|Writes the message to the debugger's output window.|
65
-
|**_CRTDBG_MODE_FILE**|Writes the message to a user-supplied file handle. [_CrtSetReportFile](crtsetreportfile.md) should be called to define the specific file or stream to use as the destination.|
66
-
|**_CRTDBG_MODE_WNDW**|Creates a message box to display the message along with the [abort](abort.md), **Retry**, and **Ignore** buttons.|
67
-
|**_CRTDBG_REPORT_MODE**|Returns *reportMode* for the specified *reportType*:<br /><br /> 1 **_CRTDBG_MODE_FILE**<br /><br /> 2 **_CRTDBG_MODE_DEBUG**<br /><br /> 4 **_CRTDBG_MODE_WNDW**|
63
+
|**`_CRTDBG_MODE_DEBUG`**|Writes the message to the debugger's output window.|
64
+
|**`_CRTDBG_MODE_FILE`**|Writes the message to a user-supplied file handle. [`_CrtSetReportFile`](crtsetreportfile.md) should be called to define the specific file or stream to use as the destination.|
65
+
|**`_CRTDBG_MODE_WNDW`**|Creates a message box to display the message along with the [`abort`](abort.md), **`Retry`**, and **Ignore** buttons.|
66
+
|**`_CRTDBG_REPORT_MODE`**|Returns *`reportMode`* for the specified *`reportType`*:<br /><br /> 1 **`_CRTDBG_MODE_FILE`**<br /><br /> 2 **`_CRTDBG_MODE_DEBUG`**<br /><br /> 4 **`_CRTDBG_MODE_WNDW`**|
68
67
69
-
Each report type can be reported using one, two, or three modes or no mode at all. Therefore, it is possible to have more than one destination defined for a single report type. For example, the following code fragment causes assertion failures to be sent to both a debug message window and to **stderr**:
68
+
Each report type can be reported using one, two, or three modes or no mode at all. Therefore, it is possible to have more than one destination defined for a single report type. For example, the following code fragment causes assertion failures to be sent to both a debug message window and to **`stderr`**:
In addition, the reporting mode or modes for each report type can be separately controlled. For example, it is possible to specify that a *reportType* of **_CRT_WARN** be sent to an output debug string, while **_CRT_ASSERT** be displayed using a debug message window and sent to **stderr**, as previously illustrated.
75
+
In addition, the reporting mode or modes for each report type can be separately controlled. For example, it is possible to specify that a *`reportType`* of **`_CRT_WARN`** be sent to an output debug string, while **`_CRT_ASSERT`** be displayed using a debug message window and sent to **`stderr`**, as previously illustrated.
0 commit comments