DEVdestroy(), change API, #1/2, klag-3.cocci for coccinelle

This commit is contained in:
rlar 2018-02-11 11:27:43 +01:00
parent 5f025050ab
commit 0ffefedd03
1 changed files with 52 additions and 0 deletions

52
klag-3.cocci Normal file
View File

@ -0,0 +1,52 @@
// DEVdestroy()
// drop the model loop
// drop the instance loop + FREE
//
// (compile "git grep -l -e 'destroy' -- '*.[ch]' | xargs -P8 -n1 spatch --sp-file klag-3.cocci --in-place && git commit -am 'DEVdestroy(), change API, #1/2, coccinelle semantic patch'")
//
// (compile "spatch --sp-file klag-3.cocci src/spicelib/devices/bjt/*.[ch]")
// (compile "spatch --sp-file klag-3.cocci src/spicelib/devices/res/resdest.c")
// (compile "spatch --sp-file klag-3.cocci src/spicelib/devices/bjt/bjtdest.c")
// (compile "spatch --sp-file klag-3.cocci src/spicelib/devices/asrc/asrcdest.c")
// (compile "spatch --sp-file klag-3.cocci src/spicelib/devices/bsim1/b1dest.c")
@unify_DEVdestroy@
identifier fn =~ "destroy$";
typedef GENmodel;
identifier XinModel;
identifier Xmod, Xinst, Xnext_mod, Xnext_inst;
identifier XXXnextModel, XXXinstances, XXXnextInstance;
type XXXmodel, XXXinstance;
@@
void fn (
- GENmodel **XinModel
+ void
)
{
- XXXmodel *Xmod = *(XXXmodel**) XinModel;
-
- while (Xmod) {
- XXXmodel *Xnext_mod = Xmod->XXXnextModel;
- XXXinstance *Xinst = Xmod->XXXinstances;
- while (Xinst) {
- XXXinstance *Xnext_inst = Xinst->XXXnextInstance;
- FREE(Xinst);
- Xinst = Xnext_inst;
- }
- FREE(Xmod);
- Xmod = Xnext_mod;
- }
-
- *XinModel = NULL;
}
@unify_DEVdestroy_h@
identifier fn =~ "destroy$";
typedef GENmodel;
@@
extern void fn (
- GENmodel **
+ void
);