tor/scripts/coccinelle/calloc.cocci
Mansour Moufid 533790ca77 The second argument to tor_calloc should be a constant.
Just like the conventional calloc.
2014-11-02 11:54:42 -05:00

17 lines
310 B
Plaintext

// Use calloc or realloc as appropriate instead of multiply-and-alloc
@malloc_to_calloc@
identifier f =~ "(tor_malloc|tor_malloc_zero)";
expression a;
constant b;
@@
- f(a * b)
+ tor_calloc(a, b)
@realloc_to_reallocarray@
expression a, b;
expression p;
@@
- tor_realloc(p, a * b)
+ tor_reallocarray(p, a, b)