mirror of
https://github.com/labwc/labwc.git
synced 2026-02-11 04:27:51 -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
|
|
@ -706,12 +706,11 @@ actions_run(struct view *activator, struct server *server,
|
|||
break;
|
||||
case ACTION_TYPE_EXECUTE:
|
||||
{
|
||||
struct buf cmd;
|
||||
buf_init(&cmd);
|
||||
struct buf cmd = BUF_INIT;
|
||||
buf_add(&cmd, action_get_str(action, "command", NULL));
|
||||
buf_expand_tilde(&cmd);
|
||||
spawn_async_no_shell(cmd.buf);
|
||||
free(cmd.buf);
|
||||
buf_reset(&cmd);
|
||||
}
|
||||
break;
|
||||
case ACTION_TYPE_EXIT:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue