free log_entries in wm_exit

This commit is contained in:
Akos Horvath 2024-04-02 11:41:37 +02:00
parent 5cbe15a899
commit 06c25ff838
2 changed files with 19 additions and 4 deletions

View File

@ -242,6 +242,7 @@ json_object* wm_state_to_json_object(Wm *wm)
free(ws_with_index->str);
free(ws_with_index);
}
wm_uintarray_free(ws_str);
return ret;
}
@ -256,7 +257,7 @@ void wm_log_state(Wm *wm, const char *prefixstr, const char* logfile)
char prefix[WM_PREFIX_LEN + 32] = {0};
snprintf(prefix, sizeof(prefix), "%lu:%s", time(NULL), prefixstr);
json_object *log_entry_obj = wm_state_to_json_object(wm, prefixstr);
json_object *log_entry_obj = wm_state_to_json_object(wm);
int fd = -1;
struct json_object *jobj = NULL;
@ -788,11 +789,12 @@ static void recursive_mkdir(char *path, mode_t mode)
void wm_logfile_init(const char *path)
{
char *dup = strdup(path);
char *log_file_dir = dirname(dup);
if (access(path, F_OK) == 0) return;
char *dup = strdup(path);
char *log_file_dir = dirname(dup);
int ret = access(log_file_dir, W_OK | R_OK);
if (ret == 0) {
@ -1373,7 +1375,18 @@ void wm_logentries_free(UIntArray *entries)
for (size_t j = 0; j < entry->workspaces->size; j++) {
TreeNode *node = entry->workspaces->nodes[j];
if (node != NULL) wm_treenode_free(node);
if (node == NULL) continue;
NodeArray *children = wm_postorder_traversal(node);
for (size_t k = 0; k < children->size; k++) {
if (children->nodes[k]->type == NODE_CLIENT) {
free(children->nodes[k]->client->name);
free(children->nodes[k]->client);
}
wm_treenode_free(children->nodes[k]);
}
wm_nodearray_free(children);
}
wm_nodearray_free(entry->workspaces);

View File

@ -535,6 +535,8 @@ void wm_exit(Wm *wm)
XftColorFree(wm->display, visual, cmap, &wm->titlebar_text_color);
XftFontClose(wm->display, wm->titlebar_font);
wm_logentries_free(wm->log_entries);
XCloseDisplay(wm->display);
exit(EXIT_SUCCESS);