cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

Suggestion for a new checker -Check Allocation Size

Open rmaman4 opened this issue 3 years ago • 1 comments

In C language, we often allocate dynamic memory using functions such as malloc, realloc, calloc, ect. When using these functions, it is important to check that the size of the allocated memory matches the size of the variable. For instance, If we would like to allocate array of integers, the size must divide by 4 (because the size of integer is 4 bytes). Usually this problem can be solved by using the function sizeof(), but this checker we have created works also when there is no use of sizeof(). It works for numbers, variables and expressions.

rmaman4 avatar May 31 '22 12:05 rmaman4

This causes a hang in TestSizeof::sizeofDivisionMemset. I cancelled the affected workflows.

firewave avatar May 31 '22 18:05 firewave

the review comments have been ignored so I close this PR

danmar avatar Aug 21 '22 16:08 danmar