Question

I've a source code that was written with wrappers to dynamic memory allocation.

something like:

wrapper_free(void *ptr);
wrapper_malloc(size_t size);

this was done to ensure portability, and as the code is third-party the problem is to fix the bugs and not rewrite it all.

I want to verify the code with cppcheck, but since cppcheck don't resolve function calls, no error in memory allocation will be found.

There is a way to change de the cppcheck functions for memory allocation/free so it will check the wrappers instead of standard functions ?

Was it helpful?

Solution

It should be possible using cppcheck config files, like:

<?xml version="1.0"?>
<def>
 <resource>
  <alloc>wrapper_malloc</alloc>
  <dealloc>wrapper_free</dealloc>
 </resource>
</def>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top