From e05e6c6e71fe60cf663ab563f75b17365ad94665 Mon Sep 17 00:00:00 2001 From: rodri Date: Wed, 3 Apr 2024 16:17:48 +0000 Subject: add trivial nil checks to some of the cleanup procedures. --- scene.c | 9 ++++++++- viewport.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scene.c b/scene.c index 6abae09..cb890a5 100644 --- a/scene.c +++ b/scene.c @@ -117,6 +117,8 @@ newmodel(void) void delmodel(Model *m) { + if(m == nil) + return; if(m->obj != nil) objfree(m->obj); if(m->tex != nil) @@ -146,7 +148,10 @@ newentity(Model *m) void delentity(Entity *e) { - delmodel(e->mdl); + if(e == nil) + return; + if(e->mdl != nil) + delmodel(e->mdl); free(e); } @@ -176,6 +181,8 @@ newscene(char *name) void delscene(Scene *s) { + if(s == nil) + return; clearscene(s); free(s->name); free(s); diff --git a/viewport.c b/viewport.c index 7f963a8..9feffaa 100644 --- a/viewport.c +++ b/viewport.c @@ -52,6 +52,8 @@ mkviewport(Rectangle r) void rmviewport(Viewport *v) { + if(v == nil) + return; rmfbctl(v->fbctl); free(v); } -- cgit v1.2.3