]> git.mdlowis.com Git - proto/labwc.git/commit
common: remove buf_init(), add BUF_INIT and buf_move()
authorJohn Lindgren <john@jlindgren.net>
Sun, 14 Apr 2024 18:20:57 +0000 (14:20 -0400)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 18 Apr 2024 06:00:23 +0000 (07:00 +0100)
commit0573f166938e22e58d84e092f6a67d79de7c1759
tree8e699a8c991dd1e3753fd6c51b27c4861035ca7b
parent343918dee06ff76beb49b31ef4861832629011a4
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.
12 files changed:
include/common/buf.h
include/common/grab-file.h
src/action.c
src/button/button-xbm.c
src/common/buf.c
src/common/dir.c
src/common/grab-file.c
src/config/rcxml.c
src/config/session.c
src/menu/menu.c
src/osd.c
src/osd_field.c