6 #include "system/nth_alloc.h"
8 #include "system/stacktrace.h"
9 #include "undo_history.h"
15 void undo_history_push(UndoHistory *undo_history,
18 size_t context_data_size)
20 trace_assert(undo_history);
22 HistoryAction action = {
26 stack_push(&undo_history->actions, context_data, context_data_size);
27 stack_push(&undo_history->actions, &action, sizeof(action));
30 void undo_history_pop(UndoHistory *undo_history)
32 trace_assert(undo_history);
34 if (stack_empty(&undo_history->actions) > 0) {
35 HistoryAction action = *(HistoryAction *)stack_top_element(&undo_history->actions);
36 stack_pop(&undo_history->actions);
38 size_t context_size = stack_top_size(&undo_history->actions);
39 void *context = stack_top_element(&undo_history->actions);
41 action.revert(context, context_size);
42 stack_pop(&undo_history->actions);