Functions malloc, calloc, realloc and free shall not be used
Functions malloc, calloc, realloc and free shall not be used.
C-style memory allocation and deallocation using malloc,
calloc, realloc, or free is not
type safe and does not invoke class's constructors/destructor to create/delete
objects.
For instance, malloc allocates memory to an object and returns a
pointer to the allocated memory of type void*. A program can then
implicitly cast the returned pointer to a different type that might not match the intended
type of the object.
The use of these allocation and deallocation functions can result in undefined behavior if:
You use free to deallocate memory allocated with operator
new.
You use operator delete to deallocate memory allocated with
malloc, calloc, or
realloc.
The rule is not violated when you perform dynamic memory allocation or
deallocation using overloaded new and delete
operators, or custom implementations of malloc and
free.
If you expect a rule violation but do not see it, refer to the documentation for Polyspace® Bug Finder™ or Polyspace Bug Finder Server™.
| Group: 18 Language Support Library |
| Category: Required, Automated |