Skip to content

Handle SDL_GetBasePath() returning null.#423

Open
xibbert wants to merge 1 commit into
commanderx16:masterfrom
xibbert:null_sdl_base_path
Open

Handle SDL_GetBasePath() returning null.#423
xibbert wants to merge 1 commit into
commanderx16:masterfrom
xibbert:null_sdl_base_path

Conversation

@xibbert

@xibbert xibbert commented Sep 20, 2022

Copy link
Copy Markdown

SDL_GetBasePath() returns null on systems that don't implement it.

Set to "./" per SDL docs example.

My OS (apparently) doesn't implement SDL_GetBasePath() and the emulator was crashing on startup.

Note: I haven't tested this on Windows, I don't have a way to do so. I don't know whether Windows gets upset about "./".

SDL_GetBasePath() returns null on systems that don't implement it.

Set to "./" per SDL docs example.
Comment thread src/main.c
char *base_path = SDL_GetBasePath();

if (!base_path) {
base_path = SDL_strdup("./");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you need to allocate a copy of this string? The following should work:

base_path = "./"

This way, you don't have to SDL_free() later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants