commandline session
$ 4.2.36 26 525---> cat source.c
#include
int
main(int argc, char *argv[])
{
unsigned int bytes = 1024 * 1024;
char *buf;
/* allocate memory */
buf = alloca(bytes);
return 0;
}
$ 4.2.36 27 526---> cat source.cocci
@@ expression E; @@
-alloca(E)
+malloc(E)
$ 4.2.36 28 527---> spatch --sp-file source.cocci source.c
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: source.c
diff =
--- source.c
+++ /tmp/cocci-output-9888-dc7b02-source.c
@@ -7,7 +7,7 @@ main(int argc, char *argv[])
char *buf;
/* allocate memory */
- buf = alloca(bytes);
+ buf = malloc(bytes);
return 0;
}
$ 4.2.36 29 528---> spatch --sp-file source.cocci source.c -o newsource.c
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: source.c
diff =
--- source.c
+++ /tmp/cocci-output-9896-231c5d-source.c
@@ -7,7 +7,7 @@ main(int argc, char *argv[])
char *buf;
/* allocate memory */
- buf = alloca(bytes);
+ buf = malloc(bytes);
return 0;
}
$ 4.2.36 30 529--->