mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
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.
This commit is contained in:
committed by
Marco Trevisan (Treviño)
parent
9b175a7681
commit
56543e1311
29
libfprint/nbis/glib-memory.cocci
Normal file
29
libfprint/nbis/glib-memory.cocci
Normal file
@@ -0,0 +1,29 @@
|
||||
@ 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) { ... }
|
||||
|
|
||||
)
|
||||
@@ -179,3 +179,5 @@ sed -i 's/[ \t]*$//' `find -name "*.[ch]"`
|
||||
# Remove usebsd.h
|
||||
sed -i '/usebsd.h/d' `find -name "*.[ch]"`
|
||||
|
||||
# Use GLib memory management
|
||||
spatch --sp-file glib-memory.cocci --dir . --in-place
|
||||
Reference in New Issue
Block a user