diff options
Diffstat (limited to 'cocci.spatches/malloc-coding-style.cocci')
-rw-r--r-- | cocci.spatches/malloc-coding-style.cocci | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cocci.spatches/malloc-coding-style.cocci b/cocci.spatches/malloc-coding-style.cocci new file mode 100644 index 0000000..90cd4da --- /dev/null +++ b/cocci.spatches/malloc-coding-style.cocci @@ -0,0 +1,27 @@ +// Apply the malloc replacements suggested in CODING_STYLE +// +// Cairo has some utility macros to check that the expressions used to +// compute the argument of a malloc() call do not overflow. +// CODING_STYLE indicates the replacements that should be done in +// order to use these functions correctly. + +// malloc (n * size + k) => _cairo_malloc_ab_plus_c (n, size, k) +@@ +expression n,size,k; +@@ +-malloc ((n) * (size) + (k)) ++_cairo_malloc_ab_plus_c (n, size, k) + +// malloc (a * b * size) => _cairo_malloc_abc (a, b, size) +@@ +expression a,b,size; +@@ +-malloc ((a) * (b) * (size)) ++_cairo_malloc3 (a, b, size) + +// malloc (n * size) => _cairo_malloc_ab (n, size) +@@ +expression n,size; +@@ +-malloc ((n) * (size)) ++_cairo_malloc_ab (n, size) |