manual: use --include instead of --append in the custom leaks section

This commit is contained in:
Daniel Marjamäki 2013-01-11 06:50:20 +01:00
parent 97b928b2bc
commit 018f6708fc
1 changed files with 8 additions and 7 deletions

View File

@ -549,8 +549,9 @@ Checking test.c...
<section> <section>
<title>User-defined allocation/deallocation functions</title> <title>User-defined allocation/deallocation functions</title>
<para>Cppcheck understands many common allocation and <para>Cppcheck understands standard allocation and
deallocation functions. But not all.</para> deallocation functions. But it doesn't know what library functions
do.</para>
<para>Here is example code that might leak memory or resources:</para> <para>Here is example code that might leak memory or resources:</para>
@ -564,11 +565,11 @@ Checking test.c...
<para>If you analyse that with Cppcheck it won't find any leaks:</para> <para>If you analyse that with Cppcheck it won't find any leaks:</para>
<programlisting>cppcheck --enable=possibleError fred1.cpp</programlisting> <programlisting>cppcheck fred1.c</programlisting>
<para>You can add some custom leaks checking by providing simple <para>You can add some custom leaks checking by providing simple
implementations for the allocation and deallocation functions. Write implementations for the allocation and deallocation functions. Write
this in a separate file:</para> this in a separate file <literal>fred.def</literal>:</para>
<programlisting>void *CreateFred() <programlisting>void *CreateFred()
{ {
@ -586,12 +587,12 @@ void DestroyFred(void *p)
<para>Now, execute <command>cppcheck</command> this way:</para> <para>Now, execute <command>cppcheck</command> this way:</para>
<programlisting>cppcheck --append=fred.cpp fred1.cpp</programlisting> <programlisting>cppcheck --include=fred.def fred1.c</programlisting>
<para>The output from <command>cppcheck</command> is:</para> <para>The output from <command>cppcheck</command> is:</para>
<programlisting>Checking fred1.cpp... <programlisting>Checking fred1.c...
[fred1.cpp:5]: (error) Memory leak: f</programlisting> [fred1.c:5]: (error) Memory leak: f</programlisting>
</section> </section>
</chapter> </chapter>