| 45 | static SDL_Hint *SDL_hints; |
| 46 | |
| 47 | SDL_bool |
| 48 | SDL_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 | |
| 98 | SDL_bool |
| 99 | SDL_SetHint(const char *name, const char *value) |
no test coverage detected