}
}
}
+
+int
+free_board(Board* board)
+{ // all the fields are being leaked rn
+
+ for (int i = 0; i < board->todolist_count; i++) {
+ TodoList* cur_todolist = board->todolist_list[i];
+
+ /* free(cur_todolist->list_name); */
+
+ for (int j = 0; j < cur_todolist->item_count; j++) {
+ TodoItem* cur_todoitem = cur_todolist->item_list[j];
+
+ /* free(cur_todoitem->item_name); */
+ /* free(cur_todoitem->description); */
+ /* free(cur_todoitem->due); */
+
+ /* free subtask later too */
+
+ free(cur_todoitem);
+ }
+
+ free(cur_todolist);
+ }
+
+ /* free(board->board_name); */
+ free(board);
+
+ return 0;
+}
case BINDING_WRITE:
{
Board* writeboard;
-
writeboard = boardmenu_to_board(boardmenu);
- /* mvprintw(30, 5, "%s", writeboard->todolist_list[0]->list_name); */
begin_write(boardfile_name, writeboard);
-
- /* now free the writeborad */
-
+ free_board(writeboard);
}
break;
Menu* curmenu = boardmenu->menu_list[i];
TodoList* new_todolist = malloc(sizeof(TodoList));
- TodoItem** item_list = malloc(sizeof(TodoItem*));
- new_todolist->list_name = get_menu_name(curmenu);
+ TodoItem** new_item_list = malloc(sizeof(TodoItem*));
+ new_todolist->list_name = strdup(get_menu_name(curmenu));
new_todolist->item_count = get_menu_length(curmenu);
for (int j = 0; j < get_menu_length(curmenu); j++) {
TodoItem* new_todoitem = malloc(sizeof(TodoItem));
- new_todoitem->item_name = get_menuitem_title(curmenuitem);
- new_todoitem->description = get_menuitem_descrip(curmenuitem);
- new_todoitem->due = 0; //TEMP!
- new_todoitem->subtask_list = 0; //TEMP!
+ new_todoitem->item_name = strdup(get_menuitem_title(curmenuitem));
+ new_todoitem->description = strdup(get_menuitem_descrip(curmenuitem));
+ new_todoitem->due = strdup(""); //TEMP!
+ new_todoitem->subtask_list = malloc(0); //TEMP!
new_todoitem->subtask_count = 0; //TEMP!
- item_list[j] = new_todoitem;
-
+ new_item_list[j] = new_todoitem;
}
- new_todolist->item_list = item_list;
-
+ new_todolist->item_list = new_item_list;
new_todolist_list[i] = new_todolist;
}
+ newboard->board_name = strdup("");
newboard->todolist_list = new_todolist_list;
newboard->todolist_count = boardmenu->menu_count;