forked from enlightenment/efl
svg/loader: use stringshare instead of malloc for storing string.
Reviewers: cedric, jpeg Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4142
This commit is contained in:
parent
570a398e29
commit
80413dda8c
|
@ -57,12 +57,12 @@ _skip_space(const char *str, const char *end)
|
|||
return (char *)str;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
static inline Eina_Stringshare *
|
||||
_copy_id(const char* str)
|
||||
{
|
||||
if (str == NULL) return NULL;
|
||||
|
||||
return strdup(str);
|
||||
return eina_stringshare_add(str);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
@ -210,7 +210,7 @@ _parse_dash_array(const char *str, Efl_Gfx_Dash** dash, int *length)
|
|||
}
|
||||
#endif
|
||||
|
||||
static char *
|
||||
static Eina_Stringshare *
|
||||
_id_from_url(const char *url)
|
||||
{
|
||||
char tmp[50];
|
||||
|
@ -230,7 +230,7 @@ static char *
|
|||
}
|
||||
tmp[i] = '\0';
|
||||
|
||||
return strdup(tmp);
|
||||
return eina_stringshare_add(tmp);
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
|
@ -407,7 +407,7 @@ static const struct {
|
|||
};
|
||||
|
||||
static inline void
|
||||
_to_color(const char *str, int *r, int *g, int *b, char** ref)
|
||||
_to_color(const char *str, int *r, int *g, int *b, Eina_Stringshare** ref)
|
||||
{
|
||||
unsigned int i, len = strlen(str);
|
||||
char *red, *green, *blue;
|
||||
|
@ -953,7 +953,7 @@ _attr_parse_path_node(void *data, const char *key, const char *value)
|
|||
|
||||
if (!strcmp(key, "d"))
|
||||
{
|
||||
path->path = strdup(value);
|
||||
path->path = eina_stringshare_add(value);
|
||||
}
|
||||
else if (!strcmp(key, "style"))
|
||||
{
|
||||
|
@ -1240,13 +1240,13 @@ _create_rect_node(Svg_Node *parent, const char *buf, unsigned buflen)
|
|||
return node;
|
||||
}
|
||||
|
||||
static char *
|
||||
static Eina_Stringshare *
|
||||
_id_from_href(const char *href)
|
||||
{
|
||||
href = _skip_space(href, NULL);
|
||||
if ((*href) == '#')
|
||||
href++;
|
||||
return strdup(href);
|
||||
return eina_stringshare_add(href);
|
||||
}
|
||||
|
||||
static Svg_Node*
|
||||
|
@ -1266,7 +1266,7 @@ _get_defs_node(Svg_Node *node)
|
|||
}
|
||||
|
||||
static Svg_Node*
|
||||
_find_child_by_id(Svg_Node *node, char *id)
|
||||
_find_child_by_id(Svg_Node *node, const char *id)
|
||||
{
|
||||
Eina_List *l;
|
||||
Svg_Node *child;
|
||||
|
@ -1362,7 +1362,7 @@ _copy_attribute(Svg_Node *to, Svg_Node *from)
|
|||
to->node.rect.ry = from->node.rect.ry;
|
||||
break;
|
||||
case SVG_NODE_PATH:
|
||||
to->node.path.path = strdup(from->node.path.path);
|
||||
to->node.path.path = eina_stringshare_add(from->node.path.path);
|
||||
break;
|
||||
case SVG_NODE_POLYGON:
|
||||
to->node.polygon.points_count = from->node.polygon.points_count;
|
||||
|
@ -1397,7 +1397,7 @@ static Eina_Bool
|
|||
_attr_parse_use_node(void *data, const char *key, const char *value)
|
||||
{
|
||||
Svg_Node *defs, *node_from, *node = data;
|
||||
char *id;
|
||||
Eina_Stringshare *id;
|
||||
|
||||
if (!strcmp(key, "xlink:href"))
|
||||
{
|
||||
|
@ -1405,7 +1405,7 @@ _attr_parse_use_node(void *data, const char *key, const char *value)
|
|||
defs = _get_defs_node(node);
|
||||
node_from = _find_child_by_id(defs, id);
|
||||
_clone_node(node_from, node);
|
||||
free(id);
|
||||
eina_stringshare_del(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3122,7 +3122,7 @@ struct _Svg_Rect_Node
|
|||
|
||||
struct _Svg_Path_Node
|
||||
{
|
||||
char *path;
|
||||
Eina_Stringshare *path;
|
||||
};
|
||||
|
||||
struct _Svg_Polygon_Node
|
||||
|
@ -3157,8 +3157,8 @@ struct _Svg_Radial_Gradient
|
|||
struct _Svg_Style_Gradient
|
||||
{
|
||||
Svg_Gradient_Type type;
|
||||
char *id;
|
||||
char *ref;
|
||||
Eina_Stringshare *id;
|
||||
Eina_Stringshare *ref;
|
||||
Efl_Gfx_Gradient_Spread spread;
|
||||
Eina_List *stops; // Efl_Gfx_Gradient_Stop
|
||||
Svg_Radial_Gradient *radial;
|
||||
|
@ -3173,7 +3173,7 @@ struct _Svg_Paint
|
|||
Eina_Bool none;
|
||||
Eina_Bool cur_color;
|
||||
Svg_Style_Gradient *gradient;
|
||||
char *url;
|
||||
Eina_Stringshare *url;
|
||||
};
|
||||
|
||||
enum _Svg_Fill_Flags
|
||||
|
@ -3234,7 +3234,7 @@ struct _Svg_Node
|
|||
Svg_Node_Type type;
|
||||
Svg_Node *parent;
|
||||
Eina_List *child;
|
||||
char *id;
|
||||
Eina_Stringshare *id;
|
||||
Svg_Style_Property *style;
|
||||
Eina_Matrix3 *transform;
|
||||
union
|
||||
|
|
Loading…
Reference in New Issue