mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-26 00:38:55 +05:30
Minor tweak to parameters in splitpld()
This commit is contained in:
parent
6cf243138e
commit
a188a19d77
15
test/main.c
15
test/main.c
@ -21,10 +21,10 @@ bool writedata(const char *basename,
|
||||
return status;
|
||||
}
|
||||
|
||||
void splitpld(const char *buffer,
|
||||
void splitpld(const char *filedata,
|
||||
unsigned int filesize,
|
||||
const struct PldHeader *ph,
|
||||
const char *name,
|
||||
unsigned int s) {
|
||||
const char *name) {
|
||||
char *wbuffer = NULL; // write buffer that will change.
|
||||
unsigned int wsize = 0; // size of wbuffer.
|
||||
unsigned int i;
|
||||
@ -33,16 +33,17 @@ void splitpld(const char *buffer,
|
||||
for (i = 0; (i + 1) < (ph -> numOffset) + 1; i++) {
|
||||
start = ph -> offsets[i];
|
||||
// the last offset still has some data until the end of file
|
||||
end = (i == (ph -> numOffset) - 1) ? s : ph -> offsets[i + 1];
|
||||
end = (i == (ph -> numOffset) - 1) ?
|
||||
filesize : ph -> offsets[i + 1];
|
||||
// copy sector to write buffer
|
||||
wsize = end - start;
|
||||
wbuffer = (char*)malloc(sizeof(char) * wsize);
|
||||
memcpy(wbuffer, buffer + start, wsize);
|
||||
memcpy(wbuffer, filedata + start, wsize);
|
||||
// create a file.
|
||||
writedata(name, i, wbuffer, wsize);
|
||||
}
|
||||
free(wbuffer);
|
||||
}
|
||||
}
|
||||
|
||||
char *loadfile(const char *fname, unsigned int *s) {
|
||||
FILE *f = fopen(fname, "rb");
|
||||
@ -80,7 +81,7 @@ bool unpackpld (const char *filedata,
|
||||
printf("fsize is %i\n", filesize);
|
||||
if (filedata != NULL && filesize != 0) {
|
||||
struct PldHeader *pldh = getpldh(filedata);
|
||||
splitpld(filedata, pldh, filename, filesize);
|
||||
splitpld(filedata, filesize, pldh, filename);
|
||||
destroypldh(pldh);
|
||||
status = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user