Definition of "used" for Rule 21.3

Moderators: misra-c, david ward

Post Reply
rgamble
Posts: 14
Joined: Fri Jul 20, 2007 7:54 pm

Definition of "used" for Rule 21.3

Post by rgamble » Tue Sep 03, 2013 5:08 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;

Steve Montgomery
Posts: 104
Joined: Fri Sep 17, 2004 1:31 pm
Company: .
Location: Northumberland or Isle of Skye

Re: Definition of "used" for Rule 21.3

Post by Steve Montgomery » Wed Sep 04, 2013 8:39 am

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.

misra-c
Posts: 561
Joined: Thu Jan 05, 2006 1:11 pm

Re: Definition of "used" for Rule 21.3

Post by misra-c » Thu Sep 12, 2013 10:32 am

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

Post Reply

Return to “8.21 Standard libraries”