[previous] MISRA C:2012  Rule-21.3:  (Required) [next] The memory allocation and deallocation functions of <stdlib.h> shall not be used

Amplification:

The identifiers calloc, malloc, realloc and free shall not be used and no macro with one of these names shall be expanded.

Example Code:


#pragma PRQA_MESSAGES_OFF 2983

#include <stdlib.h>
#include "misra.h"
#include "m3cmex.h"

#define L 4U

extern int16_t rule_2103( void )
{
   int8_t *p;

   p = ( int8_t * )malloc( L );                /* 5118 */
   free( p );                                  /* 5118 */

   p = ( int8_t * )calloc( 10U, L );           /* 5118 */
   p = ( int8_t * )realloc( p, L );            /* 5118 */

   return 1;
}



QAC messages that encompass this guideline:

5118 Use of memory allocation or deallocation function: calloc, malloc, realloc or free.



(c) The Motor Industry Research Association, 2012
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents