@@ -34,15 +34,22 @@ class DynamicMemoryManagementFunction extends Function {
3434
3535 DynamicMemoryManagementFunction ( ) {
3636 (
37- ( this instanceof AllocationFunction or this instanceof AlignedAlloc ) and
37+ ( this instanceof AllocationFunction or this instanceof AlignedAllocFunction ) and
38+ /* Avoid duplicate alerts on `realloc` which is both an `AllocationFunction` and a `DeallocationFunction`. */
39+ not this instanceof ReallocFunction and
3840 /* Placement-new expressions are not prohibited by this rule, but by Rule 21.6.3. */
3941 not this instanceof PlacementNewOrNewArrayAllocationFunction
4042 ) and
4143 description = "an expression that dynamically allocates memory"
4244 or
4345 this instanceof DeallocationFunction and
46+ /* Avoid duplicate alerts on `realloc` which is both an `AllocationFunction` and a `DeallocationFunction`. */
47+ not this instanceof ReallocFunction and
4448 description = "an expression that dynamically deallocates memory"
4549 or
50+ this instanceof ReallocFunction and
51+ description = "an expression that dynamically reallocates memory"
52+ or
4653 this instanceof AllocateOrDeallocateStdlibMemberFunction and
4754 description = "a standard library function that manages memory manually"
4855 or
@@ -67,11 +74,18 @@ class AllocateOrDeallocateStdlibMemberFunction extends MemberFunction {
6774 }
6875}
6976
77+ /**
78+ * The `std::realloc` (`<cstdlib>`) or `::realloc` (`<stdlib.h>`) function.
79+ */
80+ class ReallocFunction extends Function {
81+ ReallocFunction ( ) { this .hasGlobalOrStdName ( "realloc" ) }
82+ }
83+
7084/**
7185 * The `std::aligned_alloc` (`<cstdlib>`) or `::aligned_alloc` (`<stdlib.h>`) function.
7286 */
73- class AlignedAlloc extends Function {
74- AlignedAlloc ( ) { this .hasGlobalOrStdName ( "aligned_alloc" ) }
87+ class AlignedAllocFunction extends Function {
88+ AlignedAllocFunction ( ) { this .hasGlobalOrStdName ( "aligned_alloc" ) }
7589}
7690
7791/**
0 commit comments