MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDL_SetHintWithPriority

Function SDL_SetHintWithPriority

deps/SDL2/src/SDL_hints.c:47–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45static SDL_Hint *SDL_hints;
46
47SDL_bool
48SDL_SetHintWithPriority(const char *name, const char *value,
49 SDL_HintPriority priority)
50{
51 const char *env;
52 SDL_Hint *hint;
53 SDL_HintWatch *entry;
54
55 if (!name || !value) {
56 return SDL_FALSE;
57 }
58
59 env = SDL_getenv(name);
60 if (env && priority < SDL_HINT_OVERRIDE) {
61 return SDL_FALSE;
62 }
63
64 for (hint = SDL_hints; hint; hint = hint->next) {
65 if (SDL_strcmp(name, hint->name) == 0) {
66 if (priority < hint->priority) {
67 return SDL_FALSE;
68 }
69 if (!hint->value || !value || SDL_strcmp(hint->value, value) != 0) {
70 for (entry = hint->callbacks; entry; ) {
71 /* Save the next entry in case this one is deleted */
72 SDL_HintWatch *next = entry->next;
73 entry->callback(entry->userdata, name, hint->value, value);
74 entry = next;
75 }
76 SDL_free(hint->value);
77 hint->value = value ? SDL_strdup(value) : NULL;
78 }
79 hint->priority = priority;
80 return SDL_TRUE;
81 }
82 }
83
84 /* Couldn't find the hint, add a new one */
85 hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
86 if (!hint) {
87 return SDL_FALSE;
88 }
89 hint->name = SDL_strdup(name);
90 hint->value = value ? SDL_strdup(value) : NULL;
91 hint->priority = priority;
92 hint->callbacks = NULL;
93 hint->next = SDL_hints;
94 SDL_hints = hint;
95 return SDL_TRUE;
96}
97
98SDL_bool
99SDL_SetHint(const char *name, const char *value)

Callers 1

SDL_SetHintFunction · 0.85

Calls 5

SDL_getenvFunction · 0.85
SDL_strcmpFunction · 0.85
SDL_freeFunction · 0.85
SDL_strdupFunction · 0.85
SDL_mallocFunction · 0.85

Tested by

no test coverage detected