diff --git a/demo/extractmesh.c b/demo/extractmesh.c index 71dbe23..ba49f9b 100644 --- a/demo/extractmesh.c +++ b/demo/extractmesh.c @@ -59,10 +59,10 @@ void writemesh(const struct MeshHeader *mh, void extractmeshes(const char *filedata, const char *filename, unsigned int filesize) { - if (filedata == NULL || filesize <= 0) { + struct Header *h = NULL; + if (!(DEVIL1GEO.getheader(h, filedata))|| filesize <= 0) { return; } - struct Header *h = (struct Header*)filedata; struct MeshHeader *mh = NULL; struct Mesh m; m.b = NULL; diff --git a/demo/extracttexture.c b/demo/extracttexture.c index f686ff7..839ad84 100644 --- a/demo/extracttexture.c +++ b/demo/extracttexture.c @@ -8,10 +8,9 @@ void extracttextures(const char *filedata, struct Texture *t = NULL; struct TextureBatchDescriptor *d = NULL; char * fmt = NULL; - if (filedata == NULL || filesize == 0) { + if (!(DEVIL1TEX.getheader(p, filedata)) || filesize == 0) { return; } - p = (struct TexturePack*)filedata; fmt = (char*)malloc(strlen(filename) + 3 + 4); unsigned int i; unsigned int j; diff --git a/src/devil1geo.c b/src/devil1geo.c index d62e13b..70f5bd8 100644 --- a/src/devil1geo.c +++ b/src/devil1geo.c @@ -87,11 +87,11 @@ static bool getgheader(struct Header* h, const char* filedata) { static bool getmeshheader(struct MeshHeader **hs, unsigned int i, const char * const filedata) { - bool done = false; - if (hs == NULL || filedata == NULL) { + bool done = false; + struct Header *h = NULL; + if (hs == NULL || !(getgheader(h, filedata))) { return done; } - struct Header *h = (struct Header*)filedata; if (h -> numMesh < i) { return done; } diff --git a/src/devil1tex.c b/src/devil1tex.c index 1bbf2e9..92bc717 100644 --- a/src/devil1tex.c +++ b/src/devil1tex.c @@ -9,7 +9,7 @@ static void printtph(struct TexturePack*); static void printtbd(struct TextureBatchDescriptor*); // Get Texture Pack Header -static bool getpackheader(struct TexturePack*, const char*); +static inline bool getpackheader(struct TexturePack*, const char*); // Get Texture Batch Descriptor. static bool gettexdescriptor(struct TextureBatchDescriptor**, @@ -58,7 +58,7 @@ static void printtbd(struct TextureBatchDescriptor *bd) { } } -static bool getpackheader(struct TexturePack* p, const char *filedata) { +inline static bool getpackheader(struct TexturePack* p, const char *filedata) { if (filedata == NULL) { return false; } @@ -86,10 +86,9 @@ static bool gettexbatch(struct TextureBatch **batch, const char *filedata, unsigned int filesize) { struct TexturePack *p = NULL; - if (filedata == NULL) { // no data to get batch from. + if (!(getpackheader(p, filedata))) { return false; } - p = (struct TexturePack*)filedata; if (i > p -> batchNumber) { // no such batch in texture pack return false; }