calloc.cocci 409 B

1234567891011121314151617181920212223
  1. // Use calloc or realloc as appropriate instead of multiply-and-alloc
  2. @malloc_to_calloc@
  3. identifier f =~ "(tor_malloc|tor_malloc_zero)";
  4. expression a;
  5. constant b;
  6. @@
  7. - f(a * b)
  8. + tor_calloc(a, b)
  9. @calloc_arg_order@
  10. expression a;
  11. type t;
  12. @@
  13. - tor_calloc(sizeof(t), a)
  14. + tor_calloc(a, sizeof(t))
  15. @realloc_to_reallocarray@
  16. expression a, b;
  17. expression p;
  18. @@
  19. - tor_realloc(p, a * b)
  20. + tor_reallocarray(p, a, b)