2014-08-13 16:31:31 +02:00
|
|
|
// Use calloc or realloc as appropriate instead of multiply-and-alloc
|
|
|
|
|
|
|
|
@malloc_to_calloc@
|
2014-10-19 18:18:31 +02:00
|
|
|
identifier f =~ "(tor_malloc|tor_malloc_zero)";
|
2014-10-19 18:20:36 +02:00
|
|
|
expression a;
|
|
|
|
constant b;
|
2014-08-13 16:31:31 +02:00
|
|
|
@@
|
2014-10-19 18:18:31 +02:00
|
|
|
- f(a * b)
|
2014-08-13 16:31:31 +02:00
|
|
|
+ tor_calloc(a, b)
|
|
|
|
|
2014-10-19 18:36:46 +02:00
|
|
|
@calloc_arg_order@
|
|
|
|
expression a;
|
|
|
|
type t;
|
|
|
|
@@
|
|
|
|
- tor_calloc(sizeof(t), a)
|
|
|
|
+ tor_calloc(a, sizeof(t))
|
|
|
|
|
2014-08-13 16:31:31 +02:00
|
|
|
@realloc_to_reallocarray@
|
|
|
|
expression a, b;
|
|
|
|
expression p;
|
|
|
|
@@
|
|
|
|
- tor_realloc(p, a * b)
|
|
|
|
+ tor_reallocarray(p, a, b)
|