MISRA Discussion Forums

Full Version: Definition of "used" for Rule 21.3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The rule states, in part, "The identifiers calloc, malloc, realloc and free shall not be used" but does not define what constitutes a use. Is the following example (intended to be) a violation of Rule 21.3?

Code:
void *(*mymalloc)(size_t) = malloc;
I think that "used" here is intended to be "shall not appear in an expression" which would mean that your example violates Rule 21.3.
With reference to the Glossary definition of used, such an attempt to obfuscate the calling of a prohibited function is still a usage.

Therefore, in the example cited, the function malloc() is being used.