summaryrefslogtreecommitdiffstats
path: root/obj.c
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2010-10-16 15:17:08 -0500
committerKamil Kaminski <kamilkss@gmail.com>2010-10-16 15:17:08 -0500
commit663a667df86e36acaade5070305692f3c9199879 (patch)
treecab2230d0bf4b142969a409128e610163ca4b486 /obj.c
parent9e4401021950b72bbdf2e1db67ad393966bbd3df (diff)
downloadOBJLoader-663a667df86e36acaade5070305692f3c9199879.tar.gz
OBJLoader-663a667df86e36acaade5070305692f3c9199879.tar.bz2
OBJLoader-663a667df86e36acaade5070305692f3c9199879.zip
Add more error checking
Diffstat (limited to 'obj.c')
-rw-r--r--obj.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/obj.c b/obj.c
index 3b834e5..20f66ca 100644
--- a/obj.c
+++ b/obj.c
@@ -1,5 +1,8 @@
/* obj.c
*
+ * Kamil Kaminski
+ * kamilkss@gmail.com
+ *
* OBJ Loader
* initial code: http://www.gamedev.net/community/forums/topic.asp?topic_id=312335
*
@@ -21,6 +24,10 @@ ObjModel* ObjLoadModel(char *memory, size_t size)
/* initialize to zero */
memset(ret, 0, sizeof(ObjModel));
+ /* if size is 0, meaning file was not loaded correctly, return null */
+ if (!size)
+ return ret;
+
p = memory;
e = memory + size;
@@ -228,6 +235,9 @@ size_t ObjLoadFile(char *szFileName, char **memory)
fclose(file);
}
+ else
+ perror("fopen");
+
return bytes;
}