WRITE_STATUS_ITEM(pb, SI_file_size, "%ld\n", statbuf.st_size / 1024);
}
+static void free_status_items(void)
+{
+ freep(&status_items);
+ freep(&parser_friendly_status_items);
+}
+
static int make_status_items(void)
{
const struct lls_command *cmd = SERVER_CMD_CMD_PTR(LS);
time_t current_time;
int ret;
+ free_status_items();
if (!status_item_ls_data.path) /* no audio file open */
return 0;
ret = lls_parse(ARRAY_SIZE(argv), argv, cmd, &opts.lpr, NULL);
if (ret < 0)
goto out;
make_inode_status_items(&pb);
- free(status_items);
status_items = pb.buf;
memset(&pb, 0, sizeof(pb));
pb.max_size = shm_get_shmmax() - 1;
pb.flags = PBF_SIZE_PREFIX;
ret = print_list_item(&status_item_ls_data, &opts, &pb, current_time);
- if (ret < 0) {
- free(status_items);
- status_items = NULL;
- return ret;
- }
+ if (ret < 0)
+ goto out;
make_inode_status_items(&pb);
- free(parser_friendly_status_items);
parser_friendly_status_items = pb.buf;
ret = 1;
out:
+ if (ret < 0)
+ free_status_items();
lls_free_parse_result(opts.lpr, cmd);
return ret;
}