mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-25 16:28:57 +05:30
Fixed segmentation fault by clarifying pointer of pointer
This commit is contained in:
parent
046e1f8617
commit
9a14430a88
@ -60,7 +60,7 @@ void extractmeshes(const char *filedata,
|
||||
const char *filename,
|
||||
unsigned int filesize) {
|
||||
struct Header *h = NULL;
|
||||
if (!(DEVIL1GEO.getheader(h, filedata))|| filesize <= 0) {
|
||||
if (!(DEVIL1GEO.getheader(&h, filedata))|| filesize <= 0) {
|
||||
return;
|
||||
}
|
||||
struct MeshHeader *mh = NULL;
|
||||
|
@ -8,7 +8,7 @@ void extracttextures(const char *filedata,
|
||||
struct Texture *t = NULL;
|
||||
struct TextureBatchDescriptor *d = NULL;
|
||||
char * fmt = NULL;
|
||||
if (!(DEVIL1TEX.getheader(p, filedata)) || filesize == 0) {
|
||||
if (!(DEVIL1TEX.getheader(&p, filedata)) || filesize == 0) {
|
||||
return;
|
||||
}
|
||||
fmt = (char*)malloc(strlen(filename) + 3 + 4);
|
||||
|
@ -86,7 +86,7 @@ typedef struct {
|
||||
void (* const printcoordinate)(struct Coordinate*, unsigned int);
|
||||
|
||||
// input: pointer to struct, file data
|
||||
bool (* const getheader) (struct Header*, const char*);
|
||||
bool (* const getheader) (struct Header**, const char*);
|
||||
|
||||
// input: pointer of pointer to struct, order, file data
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
|
@ -46,7 +46,7 @@ typedef struct {
|
||||
void (* const printbatchdesc)(struct TextureBatchDescriptor*);
|
||||
|
||||
// input: pointer to struct, file data
|
||||
bool (* const getheader) (struct TexturePack*, const char*);
|
||||
bool (* const getheader) (struct TexturePack**, const char*);
|
||||
|
||||
// input: pointer of pointer to struct, order, file data, file size
|
||||
// ** = 'pass by reference' of a pointer to struct
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user