Moderators: misra-c, david ward
- Posts: 14
- Joined: Fri Jul 20, 2007 7:54 pm
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: Select all
void *(*mymalloc)(size_t) = malloc;
- Posts: 104
- Joined: Fri Sep 17, 2004 1:31 pm
- Company: .
- Location: Northumberland or Isle of Skye
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.
- Posts: 561
- Joined: Thu Jan 05, 2006 1:11 pm
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.
Posted by and on behalf of
the MISRA C Working Group