libfprint/libfprint/nbis/glib-memory.cocci
Benjamin Berg 56543e1311 nbis: Add spatch file to use GLib memory management functions
Add an spatch/coccinelle file to replace all free/malloc/realloc calls
with g_free/g_malloc/g_realloc. It also removes all the error code paths
that we do not need to check anymore.
2019-11-19 21:07:58 +01:00

29 lines
427 B
Text

@ free @
expression ptr;
@@
- free(ptr);
+ g_free(ptr);
@ malloc @
type ptr_type;
expression ptr;
expression size;
@@
- ptr = (ptr_type) malloc(size);
+ ptr = (ptr_type) g_malloc(size);
...
(
- if (ptr == (ptr_type) NULL) { ... }
|
)
@ realloc @
type ptr_type;
expression ptr;
expression size;
@@
- ptr = (ptr_type) realloc(ptr, size);
+ ptr = (ptr_type) g_realloc(ptr, size);
...
(
- if (ptr == (ptr_type) NULL) { ... }
|
)