2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 2010-2012, Daniel Stenberg, <daniel@haxx.se>, et al.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://curl.haxx.se/docs/copyright.html.
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 ###########################################################################
24 # This script scans C source files. If they seem to use memory functions,
25 # it also makes sure that it #includes the correct two header files!
27 # You can also mark a C source as fine by using 'mem-include-scan' anywhere in
34 my $dir = $ARGV[0] || die "specify directory!";
42 print STDERR "checking $file...\n";
46 if($_ =~ /(free|alloc|strdup)\(/) {
49 elsif($_ =~ /^ *# *include \"memdebug.h\"/) {
52 elsif($_ =~ /^ *# *include \"curl_memory.h\"/) {
55 elsif($_ =~ /mem-include-scan/) {
60 if($memfunc && $memdebug && $curlmem) {
68 if($memdebug && $curlmem) {
73 print STDERR "$file doesn't include \"memdebug.h\"!\n";
76 print STDERR "$file doesn't include \"curl_memory.h\"!\n";
84 opendir(my $dh, $dir) || die "can't opendir $dir: $!";
85 my @cfiles = grep { /\.c\z/ && -f "$dir/$_" } readdir($dh);
90 $errs += scanfile("$dir/$_");
94 print STDERR "----\n$errs errors detected!\n";