summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-04-03 16:17:48 +0000
committerrodri <rgl@antares-labs.eu>2024-04-03 16:17:48 +0000
commite05e6c6e71fe60cf663ab563f75b17365ad94665 (patch)
tree47f4cc76220cf52ec6cbe74eaa1bfc74c22380f0
parent930e09a2ea12275cf2e04577a170a2be342db045 (diff)
downloadlibgraphics-e05e6c6e71fe60cf663ab563f75b17365ad94665.tar.gz
libgraphics-e05e6c6e71fe60cf663ab563f75b17365ad94665.tar.bz2
libgraphics-e05e6c6e71fe60cf663ab563f75b17365ad94665.zip
add trivial nil checks to some of the cleanup procedures.
-rw-r--r--scene.c9
-rw-r--r--viewport.c2
2 files changed, 10 insertions, 1 deletions
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);
}