diff --git a/inc/log.h b/inc/log.h index fff8859..b121da6 100644 --- a/inc/log.h +++ b/inc/log.h @@ -50,12 +50,11 @@ void log_cap_lines_start(struct SList **log_cap_lines); void log_cap_lines_stop(struct SList **log_cap_lines); +void log_cap_lines_free(struct SList **log_cap_lines); + void log_cap_lines_playback(struct SList *log_cap_lines); void log_cap_lines_write(struct SList **log_cap_lines, const char *path); - -void log_cap_line_free(void *log_cap_line); - #endif // LOG_H diff --git a/src/ipc.c b/src/ipc.c index 823b49e..0671b85 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -119,7 +119,8 @@ void ipc_response_free(void *vresponse) { cfg_free(response->cfg); lid_free(response->lid); slist_free_vals(&response->heads, head_free); - slist_free_vals(&response->log_cap_lines, log_cap_line_free); + + log_cap_lines_free(&response->log_cap_lines); free(response); } @@ -132,7 +133,7 @@ void ipc_operation_free(struct IpcOperation *operation) { log_cap_lines_stop(&operation->log_cap_lines); - slist_free_vals(&operation->log_cap_lines, log_cap_line_free); + log_cap_lines_free(&operation->log_cap_lines); free(operation); } diff --git a/src/layout.c b/src/layout.c index 3f64af8..3d6bcff 100644 --- a/src/layout.c +++ b/src/layout.c @@ -308,8 +308,7 @@ void apply(void) { // TODO unique file passed to the user log_cap_lines_stop(&log_cap_lines); log_cap_lines_write(&log_cap_lines, "/tmp/wd.delta"); - - slist_free_vals(&log_cap_lines, log_cap_line_free); + log_cap_lines_free(&log_cap_lines); // all changes except mode for (i = heads_changing; i; i = i->nex) { diff --git a/src/log.c b/src/log.c index 63952de..fd1eeb7 100644 --- a/src/log.c +++ b/src/log.c @@ -187,6 +187,20 @@ void log_suppress_stop(void) { active.suppressing = false; } +void log_cap_line_free(void *data) { + struct LogCapLine *line = data; + + if (!line) { + return; + } + + if (line->line) { + free(line->line); + } + + free(line); +} + void log_cap_lines_playback(struct SList *lines) { if (!lines) return; @@ -208,6 +222,10 @@ void log_cap_lines_stop(struct SList **lines) { slist_remove_all(&log_cap_lines_active, NULL, lines); } +void log_cap_lines_free(struct SList **lines) { + slist_free_vals(lines, log_cap_line_free); +} + void log_cap_lines_write(struct SList **lines, const char *path) { // write empty to clear and validate @@ -221,17 +239,3 @@ void log_cap_lines_write(struct SList **lines, const char *path) { } } -void log_cap_line_free(void *data) { - struct LogCapLine *line = data; - - if (!line) { - return; - } - - if (line->line) { - free(line->line); - } - - free(line); -} - diff --git a/src/marshalling.cpp b/src/marshalling.cpp index e82031d..bacc0f2 100644 --- a/src/marshalling.cpp +++ b/src/marshalling.cpp @@ -1069,7 +1069,7 @@ char *marshal_ipc_response(struct IpcOperation *operation) { } // clear marshalled messages - slist_free_vals(&operation->log_cap_lines, log_cap_line_free); + log_cap_lines_free(&operation->log_cap_lines); return yaml; } diff --git a/src/server.c b/src/server.c index 5de7880..76a5e42 100644 --- a/src/server.c +++ b/src/server.c @@ -257,7 +257,7 @@ server(char *cfg_path) { log_suppress_stop(); log_cap_lines_stop(&log_cap_lines); log_cap_lines_playback(log_cap_lines); - slist_free_vals(&log_cap_lines, log_cap_line_free); + log_cap_lines_free(&log_cap_lines); // discover the lid state immediately lid_init();