6 #include "system/nth_alloc.h"
9 #include "system/stacktrace.h"
10 #include "undo_history.h"
18 UndoHistory *create_undo_history(void)
22 UndoHistory *undo_history = PUSH_LT(
24 nth_calloc(1, sizeof(UndoHistory)),
26 undo_history->lt = lt;
28 undo_history->actions = PUSH_LT(
30 create_dynarray(sizeof(Action)),
36 void destroy_undo_history(UndoHistory *undo_history)
38 trace_assert(undo_history);
39 RETURN_LT0(undo_history->lt);
42 void undo_history_push(UndoHistory *undo_history, Action action)
44 trace_assert(undo_history);
45 dynarray_push(undo_history->actions, &action);
48 void undo_history_pop(UndoHistory *undo_history)
50 trace_assert(undo_history);
52 if (dynarray_count(undo_history->actions) > 0) {
54 dynarray_pop(undo_history->actions, &action);
55 action.revert(action.layer, action.context);