#endif
}
+ // Remove duplicate paths, or it would result in duplicate extensions, duplicate devices, etc.
+ // This uses minimal memory, but is O(N^2) on the number of paths. Expect only a few paths.
+ char path_sep_str[2] = { PATH_SEPARATOR, '\0' };
+ size_t search_path_updated_size = strlen(search_path);
+ for (size_t first = 0; first < search_path_updated_size - 1; ) {
+ size_t first_end = first + 1;
+ first_end += strcspn(&search_path[first_end], path_sep_str);
+ for (size_t second = first_end + 1; second < search_path_updated_size; ) {
+ size_t second_end = second + 1;
+ second_end += strcspn(&search_path[second_end], path_sep_str);
+ if (first_end - first == second_end - second && !strncmp(&search_path[first], &search_path[second], second_end - second)) {
+ // Found duplicate. Include PATH_SEPARATOR in second_end, then erase it from search_path.
+ if (search_path[second_end] == PATH_SEPARATOR) {
+ second_end++;
+ }
+ memmove(&search_path[second], &search_path[second_end], search_path_updated_size - second_end + 1);
+ search_path_updated_size -= second_end - second;
+ } else {
+ second = second_end + 1;
+ }
+ }
+ first = first_end + 1;
+ }
+ search_path_size = search_path_updated_size;
+
// Print out the paths being searched if debugging is enabled
if (search_path_size > 0) {
loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0,