diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-29 21:54:08 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-29 22:11:08 -0400 |
commit | 849c3515abff7033dbd4723fd7328cb07af74222 (patch) | |
tree | 879dde1271572fdfe86dc0f33944100ba61a959e /common | |
parent | c91adbd188414c12f5c30d94790e3495532653a1 (diff) | |
download | sway-849c3515abff7033dbd4723fd7328cb07af74222.tar.xz |
Use statically allocated text buffer
Diffstat (limited to 'common')
-rw-r--r-- | common/pango.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/common/pango.c b/common/pango.c index 212d96cf..2ae7883c 100644 --- a/common/pango.c +++ b/common/pango.c @@ -32,7 +32,7 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, int32_t scale, bool markup, const char *fmt, ...) { - char *buf = malloc(2048); + static char buf[2048]; va_list args; va_start(args, fmt); @@ -45,12 +45,11 @@ void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, pango_cairo_update_layout(cairo, layout); pango_layout_get_pixel_size(layout, width, height); g_object_unref(layout); - free(buf); } void pango_printf(cairo_t *cairo, const char *font, int32_t scale, bool markup, const char *fmt, ...) { - char *buf = malloc(2048); + static char buf[2048]; va_list args; va_start(args, fmt); @@ -63,5 +62,4 @@ void pango_printf(cairo_t *cairo, const char *font, pango_cairo_update_layout(cairo, layout); pango_cairo_show_layout(cairo, layout); g_object_unref(layout); - free(buf); } |