Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To avoid these situations, memory should be allocated and freed at the same level of abstraction and, ideally, in the same code module. This includes the use of the following memory allocation and deallocation functions described in Section 7.23.3 of the C standard [ISO/IEC 9899:2011]:

Code Block
void *malloc(size_t size);

void *calloc(size_t nmemb, size_t size);

void *realloc(void *ptr, size_t size);

void *aligned_alloc(size_t alignment, size_t size);
 
void free(void *ptr);

...

CERT C++ Secure Coding Standard: MEM11-CPP. Allocate and free memory in the same module, at the same level of abstraction

ISO/IEC 9899:2011 Section  Section 7.23.3, "Memory management functions"

...