![]() |
![]() |
0697 | ![]() |
||||
![]() | |||||||
| Pointers | |||||||
A cast has been applied to the result of a call to malloc and this creates a pointer to an object type. However the amount of memory being allocated is not an integral multiple of the size of this object type. This is almost certainly an error. For example:
/*PRQA S 1278,1307,1336,2017,2211,3120,3198,3199,3203,3408,3602,3625,3631,3632,3672 ++*/
#include <stdlib.h>
void foo(void)
{
long * ptd;
ptd = (long *) malloc(11); /* Message 0697 */
ptd = (long *) malloc(12); /* OK */
ptd = (long *) malloc(13); /* Message 0697 */
}
No MISRA-C:2004 Rules applicable to message 0697
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |