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:
Benjamin Berg 2019-09-05 15:58:00 +02:00 committed by Marco Trevisan (Treviño)
parent 9b175a7681
commit 56543e1311
2 changed files with 31 additions and 0 deletions

View 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) { ... }
|
)

View file

@ -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