tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

calloc.cocci (409B)


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