From 663a667df86e36acaade5070305692f3c9199879 Mon Sep 17 00:00:00 2001 From: Kyle K Date: Sat, 16 Oct 2010 15:17:08 -0500 Subject: Add more error checking --- obj.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'obj.c') diff --git a/obj.c b/obj.c index 3b834e5..20f66ca 100644 --- a/obj.c +++ b/obj.c @@ -1,4 +1,7 @@ /* 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; } -- cgit v1.2.3