Fixed segmentation fault by clarifying pointer of pointer

This commit is contained in:
_
2018-04-23 17:43:04 -07:00
parent 046e1f8617
commit 9a14430a88
6 changed files with 12 additions and 12 deletions

View File

@@ -9,7 +9,7 @@ static void printmeshbatch(struct Batch*);
static void printcoordinate(struct Coordinate*, unsigned int);
static bool getgheader(struct Header*, const char*);
static bool getgheader(struct Header**, const char*);
static bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const);
@@ -76,11 +76,11 @@ static void printcoordinate(struct Coordinate *p, unsigned int count) {
}
}
static bool getgheader(struct Header* h, const char* filedata) {
static bool getgheader(struct Header** h, const char* filedata) {
if (filedata == NULL) {
return false;
}
h = (struct Header*)filedata;
(*h) = (struct Header*)filedata;
return true;
}
@@ -89,7 +89,7 @@ static bool getmeshheader(struct MeshHeader **hs,
const char * const filedata) {
bool done = false;
struct Header *h = NULL;
if (hs == NULL || !(getgheader(h, filedata))) {
if (hs == NULL || !(getgheader(&h, filedata))) {
return done;
}
if (h -> numMesh < i) {

View File

@@ -9,7 +9,7 @@ static void printtph(struct TexturePack*);
static void printtbd(struct TextureBatchDescriptor*);
// Get Texture Pack Header
static inline bool getpackheader(struct TexturePack*, const char*);
static inline bool getpackheader(struct TexturePack**, const char*);
// Get Texture Batch Descriptor.
static bool gettexdescriptor(struct TextureBatchDescriptor**,
@@ -58,11 +58,11 @@ static void printtbd(struct TextureBatchDescriptor *bd) {
}
}
inline static bool getpackheader(struct TexturePack* p, const char *filedata) {
inline static bool getpackheader(struct TexturePack** p, const char *filedata) {
if (filedata == NULL) {
return false;
}
p = (struct TexturePack*)filedata;
(*p) = (struct TexturePack*)filedata;
return true;
}
@@ -86,7 +86,7 @@ static bool gettexbatch(struct TextureBatch **batch,
const char *filedata,
unsigned int filesize) {
struct TexturePack *p = NULL;
if (!(getpackheader(p, filedata))) {
if (!(getpackheader(&p, filedata))) {
return false;
}
if (i > p -> batchNumber) { // no such batch in texture pack