Bump liberty

The bugfixes in the config parser are worth it.

I might have slightly overused cstr_set().
This commit is contained in:
Přemysl Eric Janouch 2020-10-19 19:52:48 +02:00
parent f79a8d38fb
commit a48c2cf4e5
Signed by: p
GPG Key ID: A0420B94F92B9493
6 changed files with 28 additions and 44 deletions

View File

@ -149,7 +149,7 @@ static void
app_context_free (struct app_context *self) app_context_free (struct app_context *self)
{ {
str_map_free (&self->config); str_map_free (&self->config);
free (self->current_title); cstr_set (&self->current_title, NULL);
poller_fd_reset (&self->x_event); poller_fd_reset (&self->x_event);
XCloseDisplay (self->dpy); XCloseDisplay (self->dpy);
poller_free (&self->poller); poller_free (&self->poller);
@ -207,8 +207,7 @@ update_window_title (struct app_context *ctx, char *new_title)
{ {
bool changed = !ctx->current_title != !new_title bool changed = !ctx->current_title != !new_title
|| (new_title && strcmp (ctx->current_title, new_title)); || (new_title && strcmp (ctx->current_title, new_title));
free (ctx->current_title); cstr_set (&ctx->current_title, new_title);
ctx->current_title = new_title;
return changed; return changed;
} }

View File

@ -225,12 +225,12 @@ paths_new (const char *device_path, const char *path, struct config_item *pwm)
static void static void
paths_destroy (struct paths *self) paths_destroy (struct paths *self)
{ {
free (self->temp); cstr_set (&self->temp, NULL);
free (self->pwm); cstr_set (&self->pwm, NULL);
free (self->pwm_enable); cstr_set (&self->pwm_enable, NULL);
free (self->pwm_min); cstr_set (&self->pwm_min, NULL);
free (self->pwm_max); cstr_set (&self->pwm_max, NULL);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -105,9 +105,7 @@ main (int argc, char *argv[])
"PROGRAM [ARG...]", "Run a program and restart on file change."); "PROGRAM [ARG...]", "Run a program and restart on file change.");
// We have to turn that off as it causes more trouble than what it's worth // We have to turn that off as it causes more trouble than what it's worth
char *nonpermuting = xstrdup_printf ("+%s", oh.opt_string); cstr_set (&oh.opt_string, xstrdup_printf ("+%s", oh.opt_string));
free (oh.opt_string);
oh.opt_string = nonpermuting;
int c; int c;
while ((c = opt_handler_get (&oh)) != -1) while ((c = opt_handler_get (&oh)) != -1)

@ -1 +1 @@
Subproject commit 1a76b2032e6d18d9f95d9d0bb98edc26023c8618 Subproject commit 69101eb1554ad2fca6de30cdbaccac076210d7e3

View File

@ -45,13 +45,6 @@
enum { PIPE_READ, PIPE_WRITE }; enum { PIPE_READ, PIPE_WRITE };
static void
cstr_set (char **s, char *new)
{
free (*s);
*s = new;
}
static void static void
log_message_custom (void *user_data, const char *quote, const char *fmt, log_message_custom (void *user_data, const char *quote, const char *fmt,
va_list ap) va_list ap)
@ -79,8 +72,8 @@ struct port
static void static void
port_free (struct port *self) port_free (struct port *self)
{ {
free (self->name); cstr_set (&self->name, NULL);
free (self->description); cstr_set (&self->description, NULL);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -109,14 +102,14 @@ sink_new (void)
static void static void
sink_destroy (struct sink *self) sink_destroy (struct sink *self)
{ {
free (self->name); cstr_set (&self->name, NULL);
free (self->description); cstr_set (&self->description, NULL);
for (size_t i = 0; i < self->ports_len; i++) for (size_t i = 0; i < self->ports_len; i++)
port_free (self->ports + i); port_free (self->ports + i);
free (self->ports); free (self->ports);
free (self->port_active); cstr_set (&self->port_active, NULL);
free (self); free (self);
} }
@ -185,7 +178,7 @@ app_context_free (struct app_context *self)
if (self->context) if (self->context)
pa_context_unref (self->context); pa_context_unref (self->context);
free (self->default_sink); cstr_set (&self->default_sink, NULL);
LIST_FOR_EACH (struct sink, iter, self->sinks) LIST_FOR_EACH (struct sink, iter, self->sinks)
sink_destroy (iter); sink_destroy (iter);
LIST_FOR_EACH (struct sink_input, iter, self->inputs) LIST_FOR_EACH (struct sink_input, iter, self->inputs)

View File

@ -951,7 +951,7 @@ app_context_free (struct app_context *self)
if (self->backend) self->backend->destroy (self->backend); if (self->backend) self->backend->destroy (self->backend);
poller_fd_reset (&self->x_event); poller_fd_reset (&self->x_event);
free (self->layout); cstr_set (&self->layout, NULL);
if (self->context) pa_context_unref (self->context); if (self->context) pa_context_unref (self->context);
if (self->dpy) XCloseDisplay (self->dpy); if (self->dpy) XCloseDisplay (self->dpy);
@ -966,19 +966,20 @@ app_context_free (struct app_context *self)
} }
str_free (&self->command_buffer); str_free (&self->command_buffer);
free (self->insomnia_info); cstr_set (&self->insomnia_info, NULL);
if (self->insomnia_fd != -1) if (self->insomnia_fd != -1)
xclose (self->insomnia_fd); xclose (self->insomnia_fd);
mpd_client_free (&self->mpd_client); mpd_client_free (&self->mpd_client);
free (self->mpd_song); cstr_set (&self->mpd_song, NULL);
free (self->mpd_status); cstr_set (&self->mpd_status, NULL);
nut_client_free (&self->nut_client); nut_client_free (&self->nut_client);
str_map_free (&self->nut_ups_info); str_map_free (&self->nut_ups_info);
cstr_set (&self->nut_status, NULL);
strv_free (&self->sink_ports); strv_free (&self->sink_ports);
free (self->sink_port_active); cstr_set (&self->sink_port_active, NULL);
poller_pa_destroy (self->api); poller_pa_destroy (self->api);
poller_free (&self->poller); poller_free (&self->poller);
@ -1437,8 +1438,7 @@ mpd_on_info_response (const struct mpd_response *response,
struct str_map map; struct str_map map;
mpd_vector_to_map (data, &map); mpd_vector_to_map (data, &map);
free (ctx->mpd_status); cstr_set (&ctx->mpd_status, NULL);
ctx->mpd_status = NULL;
struct str s = str_make (); struct str s = str_make ();
@ -1464,8 +1464,7 @@ mpd_on_info_response (const struct mpd_response *response,
if ((value = str_map_find (&map, "album"))) if ((value = str_map_find (&map, "album")))
str_append_printf (&s, " from \001%s\001", value); str_append_printf (&s, " from \001%s\001", value);
free (ctx->mpd_song); cstr_set (&ctx->mpd_song, str_steal (&s));
ctx->mpd_song = str_steal (&s);
refresh_status (ctx); refresh_status (ctx);
str_map_free (&map); str_map_free (&map);
@ -1708,8 +1707,7 @@ nut_on_logout_response (const struct nut_response *response, void *user_data)
while ((dict = str_map_iter_next (&iter))) while ((dict = str_map_iter_next (&iter)))
nut_process_ups (ctx, &ups_list, iter.link->key, dict); nut_process_ups (ctx, &ups_list, iter.link->key, dict);
free (ctx->nut_status); cstr_set (&ctx->nut_status, NULL);
ctx->nut_status = NULL;
if (ups_list.len) if (ups_list.len)
{ {
@ -1800,8 +1798,7 @@ nut_on_connected (void *user_data)
static void static void
nut_indicate_failure (struct app_context *ctx) nut_indicate_failure (struct app_context *ctx)
{ {
free (ctx->nut_status); cstr_set (&ctx->nut_status, xstrdup ("NUT failure"));
ctx->nut_status = xstrdup ("NUT failure");
refresh_status (ctx); refresh_status (ctx);
} }
@ -1870,8 +1867,7 @@ on_sink_info (pa_context *context, const pa_sink_info *info, int eol,
ctx->sink_muted = !!info->mute; ctx->sink_muted = !!info->mute;
strv_reset (&ctx->sink_ports); strv_reset (&ctx->sink_ports);
free (ctx->sink_port_active); cstr_set (&ctx->sink_port_active, NULL);
ctx->sink_port_active = NULL;
if (info->ports) if (info->ports)
for (struct pa_sink_port_info **iter = info->ports; *iter; iter++) for (struct pa_sink_port_info **iter = info->ports; *iter; iter++)
@ -2167,8 +2163,7 @@ static void
on_insomnia (struct app_context *ctx, int arg) on_insomnia (struct app_context *ctx, int arg)
{ {
(void) arg; (void) arg;
free (ctx->insomnia_info); cstr_set (&ctx->insomnia_info, NULL);
ctx->insomnia_info = NULL;
// Get rid of the lock if we hold one, establish it otherwise // Get rid of the lock if we hold one, establish it otherwise
if (ctx->insomnia_fd != -1) if (ctx->insomnia_fd != -1)
@ -2282,8 +2277,7 @@ on_xkb_event (struct app_context *ctx, XkbEvent *ev)
XkbDescPtr desc = XkbAllocKeyboard (); XkbDescPtr desc = XkbAllocKeyboard ();
XkbGetNames (ctx->dpy, XkbGroupNamesMask, desc); XkbGetNames (ctx->dpy, XkbGroupNamesMask, desc);
free (ctx->layout); cstr_set (&ctx->layout, NULL);
ctx->layout = NULL;
if (group != 0) if (group != 0)
{ {