mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
Fix memory leaks in swaybar
This commit is contained in:
parent
de79fee777
commit
cd5694fdb5
|
@ -94,6 +94,9 @@ static void destroy_buffer(struct buffer *buffer) {
|
|||
if (buffer->surface) {
|
||||
cairo_surface_destroy(buffer->surface);
|
||||
}
|
||||
if (buffer->pango) {
|
||||
g_object_unref(buffer->pango);
|
||||
}
|
||||
memset(buffer, 0, sizeof(struct buffer));
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,14 @@
|
|||
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text,
|
||||
int32_t scale, bool markup) {
|
||||
PangoLayout *layout = pango_cairo_create_layout(cairo);
|
||||
PangoAttrList *attrs = pango_attr_list_new();
|
||||
char *buf = malloc(2048);
|
||||
PangoAttrList *attrs;
|
||||
if (markup) {
|
||||
char *buf;
|
||||
pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, NULL);
|
||||
pango_layout_set_markup(layout, buf, -1);
|
||||
free(buf);
|
||||
} else {
|
||||
attrs = pango_attr_list_new();
|
||||
pango_layout_set_text(layout, text, -1);
|
||||
}
|
||||
pango_attr_list_insert(attrs, pango_attr_scale_new(scale));
|
||||
|
@ -25,7 +27,6 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text
|
|||
pango_layout_set_attributes(layout, attrs);
|
||||
pango_attr_list_unref(attrs);
|
||||
pango_font_description_free(desc);
|
||||
free(buf);
|
||||
return layout;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue