rspec/rules/S3530/cfamily/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

41 lines
782 B
Plaintext

== Why is this an issue?
Memory that is allocated with ``++new T[n]++`` _must_ be freed with ``++delete[]++``. Leave out the ``++[]++``, and the likely result is heap corruption or, as a best-case scenario, premature program termination.
=== Noncompliant code example
[source,cpp]
----
char *cp = new char[10];
// ...
delete cp; // Noncompliant
----
=== Compliant solution
[source,cpp]
----
char *cp = new char[10];
// ...
delete[] cp;
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
=== duplicates: S1232
=== on 10 Mar 2016, 22:29:47 Evgeny Mandrikov wrote:
Looks like duplicate of RSPEC-1232
=== on 11 Mar 2016, 08:31:55 Ann Campbell wrote:
Thanks [~evgeny.mandrikov], you're right.
endif::env-github,rspecator-view[]