Thoughts? I was think I could improve this. I use the hashmap to make sure I don't add dupes.
int PreloadIconThemes(const char *theme)
{
IconTheme *icon_theme = LoadIconTheme(theme);
if (icon_theme == NULL)
return -1;
if (themes_map == NULL)
{
themes_map = HashMapCreate2((void*)UnLoadIconTheme, NULL);
themes_names = DArrayCreate(8, free, SearchThemeNameCmp2, NULL);
}
HashMapInsert2(themes_map, theme, icon_theme);
DArrayAdd(themes_names, strdup(theme));
if (icon_theme->parents->size != 0)
{
for (int i = 0; i < icon_theme->parents->size; i++)
{
char *parent = icon_theme->parents->data[i];
if (HashMapGet2(themes_map, parent) != NULL)
{
continue;
}
if (PreloadIconThemes(parent) != 0)
continue;
}
}
return 0;
}