Stack allocated memory, like memory allocated with the functions ``++alloca++``, ``++_alloca++``, ``++_malloca++``, ``++__builtin_alloca++``, is automatically released at the end of the function, and should not be released with ``++free++``. Explicitly ``++free++``-ing such memory results in undefined behavior.


This rule raises issues when trying to release pointers to memory which is not owned, like stack allocated memory and function pointers.


== Noncompliant Code Example

----
void fun() {
  char *name = (char *) alloca(size);
  // ...
  free(name); // Noncompliant, memory allocated on the stack
  char *name2 = "name";
  // ...
  free(name2); // Noncompliant, memory allocated on the stack
}
----


== Compliant Solution

----
void fun() {
  char *name = (char *) alloca(size);
  // ...
  char *name2 = "name";
  // ...
}
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
