mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
common: remove buf_init(), add BUF_INIT and buf_move()
Add a BUF_INIT macro, which makes it easier to initialize a struct buf to an empty string (without a heap allocation). Add buf_move() to move the contents of one struct buf to another (the source is reset to BUF_INIT, analogous to C++ move-assignment). Use buf_reset() instead of directly calling `free(s->buf)` since the internal buf may not always be allocated by malloc() now.
This commit is contained in:
parent
343918dee0
commit
0573f16693
12 changed files with 122 additions and 90 deletions
|
|
@ -251,8 +251,7 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
|
|||
}
|
||||
pango_font_description_free(desc);
|
||||
|
||||
struct buf buf;
|
||||
buf_init(&buf);
|
||||
struct buf buf = BUF_INIT;
|
||||
|
||||
/* This is the width of the area available for text fields */
|
||||
int available_width = w - 2 * theme->osd_border_width
|
||||
|
|
@ -319,7 +318,7 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
|
|||
|
||||
y += theme->osd_window_switcher_item_height;
|
||||
}
|
||||
free(buf.buf);
|
||||
buf_reset(&buf);
|
||||
g_object_unref(layout);
|
||||
|
||||
cairo_surface_flush(surf);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue