typedef struct Efreet_Icon_Cache Efreet_Icon_Cache;
struct Efreet_Icon_Cache
{
- char *key;
- char *path;
+ const char *key;
+ const char *path;
time_t lasttime;
};
/* setup the default extension list */
for (i = 0; default_exts[i] != NULL; i++)
- efreet_icon_extensions = eina_list_append(efreet_icon_extensions, strdup(default_exts[i]));
+ efreet_icon_extensions = eina_list_append(efreet_icon_extensions, eina_stringshare_add(default_exts[i]));
efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_theme_free));
IF_FREE(efreet_icon_user_dir);
IF_FREE(efreet_icon_deprecated_user_dir);
- IF_FREE_LIST(efreet_icon_extensions, free);
+ IF_FREE_LIST(efreet_icon_extensions, eina_stringshare_del);
IF_FREE_HASH(efreet_icon_themes);
efreet_extra_icon_dirs = eina_list_free(efreet_extra_icon_dirs);
EAPI void
efreet_icon_extension_add(const char *ext)
{
- efreet_icon_extensions = eina_list_prepend(efreet_icon_extensions, strdup(ext));
+ efreet_icon_extensions = eina_list_prepend(efreet_icon_extensions, eina_stringshare_add(ext));
}
/**
char *p;
icon = NEW(Efreet_Icon, 1);
- icon->path = strdup(path);
+ icon->path = eina_stringshare_add(path);
/* load the .icon file if it's available */
p = strrchr(icon->path, '.');
file = ecore_file_file_get(icon->path);
p = strrchr(icon->path, '.');
if (p) *p = '\0';
- icon->name = strdup(file);
+ icon->name = eina_stringshare_add(file);
if (p) *p = '.';
}
icon->ref_count --;
if (icon->ref_count > 0) return;
- IF_FREE(icon->path);
- IF_FREE(icon->name);
+ IF_RELEASE(icon->path);
+ IF_RELEASE(icon->name);
IF_FREE_LIST(icon->attach_points, free);
FREE(icon);
efreet_ini_section_set(ini, "Icon Data");
tmp = efreet_ini_localestring_get(ini, "DisplayName");
- if (tmp) icon->name = strdup(tmp);
+ if (tmp) icon->name = eina_stringshare_add(tmp);
tmp = efreet_ini_string_get(ini, "EmbeddedTextRectangle");
if (tmp)
int points[4];
char *t, *s, *p;
int i;
+ size_t len;
- t = strdup(tmp);
+ len = strlen(tmp) + 1;
+ t = alloca(len);
+ memcpy(t, tmp, len);
s = t;
for (i = 0; i < 4; i++)
{
icon->embedded_text_rectangle.y0 = points[1];
icon->embedded_text_rectangle.x1 = points[2];
icon->embedded_text_rectangle.y1 = points[3];
-
- FREE(t);
}
tmp = efreet_ini_string_get(ini, "AttachPoints");
if (tmp)
{
char *t, *s, *p;
+ size_t len;
- t = strdup(tmp);
+ len = strlen(tmp) + 1;
+ t = alloca(len);
+ memcpy(t, tmp, len);
s = t;
while (s)
{
if (p) s = ++p;
else s = NULL;
}
- FREE(t);
}
efreet_ini_free(ini);
IF_RELEASE(theme->name.internal);
IF_RELEASE(theme->name.name);
- IF_FREE(theme->comment);
- IF_FREE(theme->example_icon);
+ IF_RELEASE(theme->comment);
+ IF_RELEASE(theme->example_icon);
- IF_FREE_LIST(theme->paths, free);
- IF_FREE_LIST(theme->inherits, free);
+ IF_FREE_LIST(theme->paths, eina_stringshare_del);
+ IF_FREE_LIST(theme->inherits, eina_stringshare_del);
IF_FREE_LIST(theme->directories, efreet_icon_theme_directory_free);
FREE(theme);
if (!theme || !path) return;
if (!eina_list_search_unsorted(theme->paths, EINA_COMPARE_CB(strcmp), path))
- theme->paths = eina_list_append(theme->paths, strdup(path));
+ theme->paths = eina_list_append(theme->paths, eina_stringshare_add(path));
}
/**
if (tmp) theme->name.name = eina_stringshare_add(tmp);
tmp = efreet_ini_localestring_get(ini, "Comment");
- if (tmp) theme->comment = strdup(tmp);
+ if (tmp) theme->comment = eina_stringshare_add(tmp);
tmp = efreet_ini_string_get(ini, "Example");
- if (tmp) theme->example_icon = strdup(tmp);
+ if (tmp) theme->example_icon = eina_stringshare_add(tmp);
theme->hidden = efreet_ini_boolean_get(ini, "Hidden");
if (tmp)
{
char *t, *s, *p;
+ size_t len;
- t = strdup(tmp);
+ len = strlen(tmp) + 1;
+ t = alloca(len);
+ memcpy(t, tmp, len);
s = t;
p = strchr(s, ',');
{
*p = '\0';
- theme->inherits = eina_list_append(theme->inherits, strdup(s));
+ theme->inherits = eina_list_append(theme->inherits, eina_stringshare_add(s));
s = ++p;
p = strchr(s, ',');
}
- theme->inherits = eina_list_append(theme->inherits, strdup(s));
-
- FREE(t);
+ theme->inherits = eina_list_append(theme->inherits, eina_stringshare_add(s));
}
/* make sure this one is done last as setting the directory will change
if (tmp)
{
char *t, *s, *p;
+ size_t len;
- t = strdup(tmp);
+ len = strlen(tmp) + 1;
+ t = alloca(len);
+ memcpy(t, tmp, len);
s = t;
p = s;
if (p) s = ++p;
}
-
- FREE(t);
}
efreet_ini_free(ini);
if (!ini) return NULL;
dir = NEW(Efreet_Icon_Theme_Directory, 1);
- dir->name = strdup(name);
+ dir->name = eina_stringshare_add(name);
efreet_ini_section_set(ini, name);
{
if (!dir) return;
- IF_FREE(dir->name);
+ IF_RELEASE(dir->name);
FREE(dir);
}
{
if (!value) return;
- IF_FREE(value->key);
- IF_FREE(value->path);
+ IF_RELEASE(value->key);
+ IF_RELEASE(value->path);
free(value);
}
snprintf(key, sizeof(key), "%s %d", icon, size);
cache = NEW(Efreet_Icon_Cache, 1);
- cache->key = strdup(key);
+ cache->key = eina_stringshare_add(key);
if ((value) && !stat(value, &st))
{
- cache->path = strdup(value);
+ cache->path = eina_stringshare_add(value);
cache->lasttime = st.st_mtime;
}
else
const char *name; /**< The user visible name */
} name; /**< The different names for the theme */
- char *comment; /**< String describing the theme */
- char *example_icon; /**< Icon to use as an example of the theme */
+ const char *comment; /**< String describing the theme */
+ const char *example_icon; /**< Icon to use as an example of the theme */
/* An icon theme can have multiple directories that store it's icons. We
* need to be able to find a search each one. */
*/
struct Efreet_Icon_Theme_Directory
{
- char *name; /**< The directory name */
+ const char *name; /**< The directory name */
Efreet_Icon_Theme_Context context; /**< The type of icons in the dir */
Efreet_Icon_Size_Type type; /**< The size type for the icons */
*/
struct Efreet_Icon
{
- char *path; /**< Full path to the icon */
- char *name; /**< Translated UTF8 string that can
+ const char *path; /**< Full path to the icon */
+ const char *name; /**< Translated UTF8 string that can
be used for the icon name */
struct
static int _efreet_ini_log_dom = -1;
static Eina_Hash *efreet_ini_parse(const char *file);
-static char *efreet_ini_unescape(const char *str);
+static const char *efreet_ini_unescape(const char *str);
static Eina_Bool
efreet_ini_section_save(const Eina_Hash *hash, const void *key, void *data, void *fdata);
static Eina_Bool
memcpy((char*)header, line_start + 1, header_length - 1);
((char*)header)[header_length - 1] = '\0';
- section = eina_hash_string_small_new(free);
+ section = eina_hash_string_small_new(EINA_FREE_CB(eina_stringshare_del));
- eina_hash_del(data, header, NULL);
+ eina_hash_del_by_key(data, header);
// if (old) INF("[efreet] Warning: duplicate section '%s' "
// "in file '%s'", header, file);
value_end - value_start);
((char*)value)[value_end - value_start] = '\0';
- eina_hash_del(section, key, NULL);
+ eina_hash_del_by_key(section, key);
eina_hash_add(section, key, efreet_ini_unescape(value));
}
// else
ini->data = eina_hash_string_small_new(EINA_FREE_CB(eina_hash_free));
if (eina_hash_find(ini->data, section)) return;
- hash = eina_hash_string_small_new(free);
+ hash = eina_hash_string_small_new(EINA_FREE_CB(eina_stringshare_del));
eina_hash_add(ini->data, section, hash);
}
{
if (!ini || !key || !ini->section) return;
- eina_hash_del(ini->section, key, NULL);
- eina_hash_add(ini->section, key, strdup(value));
+ eina_hash_del_by_key(ini->section, key);
+ eina_hash_add(ini->section, key, eina_stringshare_add(value));
}
/**
{
if (!ini || !key || !ini->section) return;
- eina_hash_del(ini->section, key, NULL);
+ eina_hash_del_by_key(ini->section, key);
}
/**
* @return An allocated unescaped string
* @brief Unescapes backslash escapes in a string
*/
-static char *
+static const char *
efreet_ini_unescape(const char *str)
{
char *buf, *dest;
const char *p;
if (!str) return NULL;
- if (!strchr(str, '\\')) return strdup(str);
- buf = malloc(strlen(str) + 1);
+ if (!strchr(str, '\\')) return eina_stringshare_add(str);
+ buf = alloca(strlen(str) + 1);
p = str;
dest = buf;
- while(*p)
+ while (*p)
{
if ((*p == '\\') && (p[1] != '\0'))
{
}
*(dest) = '\0';
- return buf;
+ return eina_stringshare_add(buf);
}
static Eina_Bool