Skip to content

Commit 76fe6dc

Browse files
TylerMSFTTylerMSFT
authored andcommitted
acrolinx
1 parent 2275fe3 commit 76fe6dc

File tree

2 files changed

+43
-45
lines changed

2 files changed

+43
-45
lines changed
Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
---
2-
description: "Learn more about: _CrtMemDifference"
32
title: "_CrtMemDifference"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: _CrtMemDifference"
4+
ms.date: "3/8/2021"
55
api_name: ["_CrtMemDifference"]
66
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
77
api_type: ["DLLExport"]
88
topic_type: ["apiref"]
99
f1_keywords: ["_CrtMemDifference", "CrtMemDifference"]
1010
helpviewer_keywords: ["CrtMemDifference function", "_CrtMemDifference function"]
11-
ms.assetid: 0f327278-b551-482f-958b-76941f796ba4
1211
---
13-
# _CrtMemDifference
12+
# `_CrtMemDifference`
1413

1514
Compares two memory states and returns their differences (debug version only).
1615

@@ -26,36 +25,36 @@ int _CrtMemDifference(
2625

2726
### Parameters
2827

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).
3130

32-
*oldState*\
33-
Pointer to an earlier memory state (**_CrtMemState** structure).
31+
*`oldState`*\
32+
Pointer to an earlier memory state (**`_CrtMemState`** structure).
3433

35-
*newState*\
36-
Pointer to a later memory state (**_CrtMemState** structure).
34+
*`newState`*\
35+
Pointer to a later memory state (**`_CrtMemState`** structure).
3736

3837
## Return Value
3938

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.
4140

4241
## Remarks
4342

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.
4544

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.
4746

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`*.
4948

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`.
5150

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).
5352

5453
## Requirements
5554

5655
|Routine|Required header|Optional header|
5756
|-------------|---------------------|---------------------|
58-
|**_CrtMemDifference**|\<crtdbg.h>|\<errno.h>|
57+
|**`_CrtMemDifference`**|`<crtdbg.h>`|`<errno.h>`|
5958

6059
For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
6160

@@ -64,4 +63,4 @@ For more compatibility information, see [Compatibility](../../c-runtime-library/
6463
## See also
6564

6665
[Debug Routines](../../c-runtime-library/debug-routines.md)\
67-
[_crtDbgFlag](../../c-runtime-library/crtdbgflag.md)\
66+
[`_crtDbgFlag`](../../c-runtime-library/crtdbgflag.md)\
Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
---
2-
description: "Learn more about: _CrtSetReportMode"
32
title: "_CrtSetReportMode"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: _CrtSetReportMode"
4+
ms.date: "3/8/2021"
55
api_name: ["_CrtSetReportMode"]
66
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
77
api_type: ["DLLExport"]
88
topic_type: ["apiref"]
99
f1_keywords: ["_CrtSetReportMode", "CrtSetReportMode"]
1010
helpviewer_keywords: ["_CrtSetReportMode function", "CrtSetReportMode function"]
11-
ms.assetid: 3ecc6a12-afdd-4242-b046-8187ff6d4b36
1211
---
13-
# _CrtSetReportMode
12+
# `_CrtSetReportMode`
1413

15-
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).
1615

1716
## Syntax
1817

@@ -25,66 +24,66 @@ int _CrtSetReportMode(
2524

2625
### Parameters
2726

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`**.
3029

31-
*reportMode*<br/>
32-
New report mode or modes for *reportType*.
30+
*`reportMode`*\
31+
New report mode or modes for *`reportType`*.
3332

3433
## Return Value
3534

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).
3736

3837
## Remarks
3938

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.
4140

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.
4342

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:
4544

4645
- Assertion failures and errors are directed to a debug message window.
4746

4847
- Warnings from Windows applications are sent to the debugger's output window.
4948

5049
- Warnings from console applications are not displayed.
5150

52-
The following table lists the report types defined in Crtdbg.h.
51+
The following table lists the report types defined in `Crtdbg.h`.
5352

5453
|Report type|Description|
5554
|-----------------|-----------------|
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`**).|
5958

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.
6160

6261
|Report mode|_CrtDbgReport behavior|
6362
|-----------------|-----------------------------|
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`**|
6867

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`**:
7069

7170
```C
7271
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_WNDW );
7372
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
7473
```
7574
76-
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.
7776
7877
## Requirements
7978
8079
|Routine|Required header|Optional header|
8180
|-------------|---------------------|---------------------|
82-
|**_CrtSetReportMode**|\<crtdbg.h>|\<errno.h>|
81+
|**`_CrtSetReportMode`**|`<crtdbg.h>`|`<errno.h>`|
8382
8483
For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
8584
86-
**Libraries:** Debug versions of [C runtime libraries](../../c-runtime-library/crt-library-features.md) only.
85+
**Libraries:** Debug versions of the [C runtime libraries](../../c-runtime-library/crt-library-features.md) only.
8786
8887
## See also
8988
90-
[Debug Routines](../../c-runtime-library/debug-routines.md)<br/>
89+
[Debug Routines](../../c-runtime-library/debug-routines.md)

0 commit comments

Comments
 (0)