mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
Add platform-specific fixes file
Create a new file, platform.h, for platform-specific hacks for MSVC, this includes defining strncasecmp to _stricmp and strdup to _strdup, among other things like defining missing stat macros Change some things not supported in MSVC, like _Static_assert, to their counterparts (in this case, static_assert) Replace usage of VLAs with malloc and free Update getopt_long and use the getopt implementation from musl on Windows. Use comments to show which functions from platform.h are being used
This commit is contained in:
@@ -454,9 +454,8 @@ void obj_ReadFile(char const *fileName)
|
||||
symbolList->next = symbolLists;
|
||||
symbolLists = symbolList;
|
||||
|
||||
uint32_t nbSymPerSect[nbSections ? nbSections : 1];
|
||||
|
||||
memset(nbSymPerSect, 0, sizeof(nbSymPerSect));
|
||||
uint32_t *nbSymPerSect = calloc(nbSections ? nbSections : 1,
|
||||
sizeof(*nbSymPerSect));
|
||||
|
||||
verbosePrint("Reading %" PRIu32 " symbols...\n", nbSymbols);
|
||||
for (uint32_t i = 0; i < nbSymbols; i++) {
|
||||
@@ -475,7 +474,8 @@ void obj_ReadFile(char const *fileName)
|
||||
}
|
||||
|
||||
/* This file's sections, stored in a table to link symbols to them */
|
||||
struct Section *fileSections[nbSections ? nbSections : 1];
|
||||
struct Section **fileSections = malloc(sizeof(*fileSections)
|
||||
* (nbSections ? nbSections : 1));
|
||||
|
||||
verbosePrint("Reading %" PRIu32 " sections...\n", nbSections);
|
||||
for (uint32_t i = 0; i < nbSections; i++) {
|
||||
@@ -501,6 +501,8 @@ void obj_ReadFile(char const *fileName)
|
||||
sect_AddSection(fileSections[i]);
|
||||
}
|
||||
|
||||
free(nbSymPerSect);
|
||||
|
||||
/* Give symbols pointers to their sections */
|
||||
for (uint32_t i = 0; i < nbSymbols; i++) {
|
||||
int32_t sectionID = fileSymbols[i]->sectionID;
|
||||
@@ -539,6 +541,7 @@ void obj_ReadFile(char const *fileName)
|
||||
assertions = assertion;
|
||||
}
|
||||
|
||||
free(fileSections);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user