Skip to content

More functions that could use the SDL_GetStringRule... #10229

@icculus

Description

@icculus

There are a handful of things that allocate strings for return values that we expect the app to free.

Should these be changed to return const char * and follow the SDL_GetStringRule, so the app doesn't have to free it, they just have to use it and be done? (or copy it if they want to keep it around).

These are the things that return char * with obvious non-allocations (SDL_getenv, SDL_strlwr, etc) filtered out.

SDL_stdinc.h:2895:extern SDL_DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
SDL_clipboard.h:75:extern SDL_DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
SDL_clipboard.h:120:extern SDL_DECLSPEC char * SDLCALL SDL_GetPrimarySelectionText(void);
SDL_filesystem.h:83:extern SDL_DECLSPEC char *SDLCALL SDL_GetBasePath(void);
SDL_filesystem.h:140:extern SDL_DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app);
SDL_filesystem.h:243:extern SDL_DECLSPEC char *SDLCALL SDL_GetUserFolder(SDL_Folder folder);
SDL_filesystem.h:380:extern SDL_DECLSPEC char **SDLCALL SDL_GlobDirectory(const char *path, const char *pattern, SDL_GlobFlags flags, int *count);
SDL_storage.h:404:extern SDL_DECLSPEC char **SDLCALL SDL_GlobStorageDirectory(SDL_Storage *storage, const char *path, const char *pattern, SDL_GlobFlags flags, int *count);
SDL_gamepad.h:402:extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
SDL_gamepad.h:418:extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_JoystickGUID guid);
SDL_gamepad.h:438:extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
SDL_gamepad.h:663:extern SDL_DECLSPEC char *SDLCALL SDL_GetGamepadInstanceMapping(SDL_JoystickID instance_id);

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions