diff options
-rw-r--r-- | scripts/coccinelle/calloc.cocci | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/coccinelle/calloc.cocci b/scripts/coccinelle/calloc.cocci new file mode 100644 index 0000000000..8a295eb4fd --- /dev/null +++ b/scripts/coccinelle/calloc.cocci @@ -0,0 +1,20 @@ +// Use calloc or realloc as appropriate instead of multiply-and-alloc + +@malloc_to_calloc@ +expression a,b; +@@ +- tor_malloc(a * b) ++ tor_calloc(a, b) + +@malloc_zero_to_calloc@ +expression a, b; +@@ +- tor_malloc_zero(a * b) ++ tor_calloc(a, b) + +@realloc_to_reallocarray@ +expression a, b; +expression p; +@@ +- tor_realloc(p, a * b) ++ tor_reallocarray(p, a, b) |