diff --git a/include/devil1pld.h b/include/devil1pld.h index b640184..93a006d 100644 --- a/include/devil1pld.h +++ b/include/devil1pld.h @@ -13,16 +13,12 @@ struct PldHeader { #pragma pack(pop) -// input: contents of the .pld file. -// allocates heap memory -//struct PldHeader *getpldh(const char*); - +// input: pointer to a struct, contents of the .pld file. +// * = pass by reference of a struct PldHeader bool getpldh(struct PldHeader*, const char*); -// frees heap memory -void destroypldh(struct PldHeader*); - // input: a pld header struct. +// * = pass by reference of a struct PldHeader void printpldh(struct PldHeader*); #endif \ No newline at end of file diff --git a/src/devil1pld.c b/src/devil1pld.c index 8d2bcff..1f55484 100644 --- a/src/devil1pld.c +++ b/src/devil1pld.c @@ -1,35 +1,5 @@ #include "devil1pld.h" #include -#include -#include - -/* struct PldHeader *getpldh(const char *filedata) { - if (filedata == NULL) { - return NULL; - } - int32_t *n = (int32_t*)filedata; - struct PldHeader *ph = (struct PldHeader*)malloc( - sizeof(struct PldHeader) - ); - uint32_t size_offsets = sizeof(uint32_t) * n[0]; - ph -> offsets = (uint32_t*)malloc(size_offsets); - if (ph -> offsets == NULL) { - perror("Error 4: "); - free(ph); - free(ph -> offsets); - return NULL; - } - // set data of struct. - ph -> numOffset = n[0]; - memcpy(ph -> offsets, filedata + sizeof(int32_t), size_offsets); - return ph; -} */ - -void destroypldh(struct PldHeader *ph) { - free(ph -> offsets); - free(ph); - ph = NULL; -} bool getpldh(struct PldHeader *ph, const char *filedata) { bool good = false;