diff options
author | Kyle K <kylek389@gmail.com> | 2010-10-16 15:17:08 -0500 |
---|---|---|
committer | Kamil Kaminski <kamilkss@gmail.com> | 2010-10-16 15:17:08 -0500 |
commit | 663a667df86e36acaade5070305692f3c9199879 (patch) | |
tree | cab2230d0bf4b142969a409128e610163ca4b486 /obj.c | |
parent | 9e4401021950b72bbdf2e1db67ad393966bbd3df (diff) | |
download | OBJLoader-663a667df86e36acaade5070305692f3c9199879.tar.gz OBJLoader-663a667df86e36acaade5070305692f3c9199879.tar.bz2 OBJLoader-663a667df86e36acaade5070305692f3c9199879.zip |
Add more error checking
Diffstat (limited to 'obj.c')
-rw-r--r-- | obj.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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; } |