Compare commits

..

No commits in common. "31d78bfcd3e39217b256345cdf82ba96cdbf59ae" and "7fd7bc4dfa009574c15d8f7f7e8b97a5eb81afb4" have entirely different histories.

2 changed files with 5 additions and 46 deletions

24
.vscode/launch.json vendored
View File

@ -54,30 +54,6 @@
"ignoreFailures": true "ignoreFailures": true
} }
] ]
},
{
"name": "(gdb) Debug pakrd_test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/pakrd_test",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
} }
] ]
} }

View File

@ -132,7 +132,7 @@ asset_pack_t *load_asset_pack(const char *filepath) {
pack->fp = fopen(full_path, "rb"); pack->fp = fopen(full_path, "rb");
if (!(pack->fp)) { if (!(pack->fp)) {
close_asset_pack(&pack); free(pack);
return NULL; return NULL;
} }
@ -145,29 +145,16 @@ asset_pack_t *load_asset_pack(const char *filepath) {
pack->toc = (u8 *)malloc(toc_size); pack->toc = (u8 *)malloc(toc_size);
if (!(pack->toc)) { if (!(pack->toc)) {
close_asset_pack(&pack); fclose(pack->fp);
free(pack);
return NULL; return NULL;
} }
fread((void *)(pack->toc), toc_size, 1, pack->fp); fread((void *)(pack->toc), toc_size, 1, pack->fp);
u64 entries_size = sizeof(toc_entry_t *) * pack->header.toc.count; // TODO (Abdelrahman): Populate the entries array
pack->toc_entries = (toc_entry_t **)malloc(entries_size);
if (!(pack->toc_entries)) {
close_asset_pack(&pack);
return NULL;
}
toc_entry_t *next = (toc_entry_t *)pack->toc;
for (u64 i = 0; i < pack->header.toc.count; ++i) {
pack->toc_entries[i] = next;
next = (toc_entry_t *)((u8 *)next + sizeof(toc_entry_t) + next->length);
}
pack->assets_offset = ftell(pack->fp); pack->assets_offset = ftell(pack->fp);
@ -183,10 +170,6 @@ void close_asset_pack(asset_pack_t **pack) {
return; return;
} }
if ((*pack)->toc_entries) {
free((*pack)->toc_entries);
}
if ((*pack)->toc) { if ((*pack)->toc) {
free((*pack)->toc); free((*pack)->toc);
} }