1+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
2+ <html xmlns =" http://www.w3.org/1999/xhtml" xml:lang =" en" >
3+ <head >
4+ <meta http-equiv = " Content-Type" content = " text/html; charset=UTF-8" />
5+ <title >Developer Information - Cppcheck</title >
6+ <link rel = " stylesheet" type = " text/css" href = " http://fonts.googleapis.com/css?family=Orbitron& ; text=Cppcheck" />
7+ <link rel = " stylesheet" type = " text/css" href = " /site/css/all.css" />
8+ <link rel = " shortcut icon" type = " image/x-icon" href = " /favicon.ico" />
9+ <link rel = " alternate" type = " application/atom+xml" title = " Recent Commits to cppcheck:master"
10+ href = " https://github.com/danmar/cppcheck/commits/master.atom" />
11+ <link rel = " alternate" type = " application/atom+xml" title = " Trac Timeline"
12+ href = " http://sourceforge.net/apps/trac/cppcheck/timeline?changeset=on& ; ticket=on& ; milestone=on& ; wiki=on& ; max=50& ; daysback=90& ; format=rss" />
13+ <script src = " https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type = " text/javascript" ></script >
14+ <script src = " /site/js/github.js" type = " text/javascript" ></script >
15+ <script type = " text/javascript" >
16+ function checkCodeLength() {
17+ if (document . f . code . value . length > 1024 ) {
18+ alert (' code length exceeded' );
19+ return false ;
20+ }
21+ return true ;
22+ }
23+ </script >
24+ </head >
25+ <body >
26+ <div id =" header" >
27+ <div class = " wrap" >
28+ <h1 >Cppcheck</h1 >
29+ <p >A tool for static C/C++ code analysis</p >
30+ </div > <!-- .wrap -->
31+ </div > <!-- #header -->
32+ <div id =" tabs" >
33+ <div class = " wrap" >
34+ <ul >
35+ <li ><a href = " /" >Home</a ></li >
36+ <li ><a href = " http://sourceforge.net/apps/mediawiki/cppcheck/" >Wiki</a ></li >
37+ <li ><a href = " http://sourceforge.net/apps/phpbb/cppcheck/" >Forum</a ></li >
38+ <li ><a href = " http://sourceforge.net/apps/trac/cppcheck/" >Trac</a ></li >
39+ <li ><a href = " /devinfo/" title = " Developer Information" >Developer Info</a ></li >
40+ <li ><strong ><a href = " /demo/" >Online Demo</a ></strong ></li >
41+ <li ><a href = " http://sourceforge.net/projects/cppcheck/" >Project page</a ></li >
42+ </ul >
43+ </div > <!-- .wrap -->
44+ </div > <!-- #tabs -->
45+ <div id =" content" >
46+ <div class = " wrap" >
47+ <h2 >Online Demo</h2 >
48+ <form action = " http://cppcheck.sourceforge.net/cgi-bin/democlient.cgi" name = " f" onsubmit = " return checkCodeLength();" method = " post" target = " _blank" >
49+ <p ><label for = " code" >Enter code:</label ><br />
50+ <textarea id = " code" name = " code" rows = " 20" cols = " 80" >
51+ void f()
52+ {
53+ char * p ;
54+ * p = 0 ;
55+ }
56+ </textarea ><br />
57+ <input type = " submit" value = " Check" /> (max 1024 characters)</p >
58+ </form >
59+ <h3 >Examples</h3 >
60+ <p >This code can be copy and pasted in the edit box above.</p >
61+ <h4 >NULL pointers</h4 >
62+ <pre class = " code" >void f1(struct fred_t *p)
63+ {
64+ <em >// dereference p and then check if it's NULL</em >
65+ int x = p - & gt ;x ;
66+ if (p )
67+ do_something (x );
68+ }
69+
70+ void f2()
71+ {
72+ const char * p = NULL ;
73+ for (int i = 0 ; str [i ] != ' \0' ; i ++ )
74+ {
75+ if (str [i ] == ' ' )
76+ {
77+ p = str + i ;
78+ break ;
79+ }
80+ }
81+
82+ <em >// p is NULL if str doesn't have a space. If str always has a</em >
83+ <em >// a space then the condition (str[i] != '\0') would be redundant</em >
84+ return p [1 ];
85+ }
86+
87+ void f3(int a)
88+ {
89+ struct fred_t * p = NULL ;
90+ if (a == 1 )
91+ p = fred1 ;
92+
93+ <em >// if a is not 1 then p is NULL</em >
94+ p - & gt ;x = 0 ;
95+ } </pre >
96+ </div > <!-- .wrap -->
97+ </div > <!-- #content -->
98+ </body >
99+ </html >
0 commit comments