#ifndef UNDO_HISTORY_H_ #define UNDO_HISTORY_H_ #include "ring_buffer.h" typedef void (*RevertAction)(void *context, size_t context_size); typedef struct { RingBuffer actions; } UndoHistory; UndoHistory create_undo_history(void); static inline void destroy_undo_history(UndoHistory undo_history) { destroy_ring_buffer(undo_history.actions); } void undo_history_push(UndoHistory *undo_history, RevertAction revert, void *context_data, size_t context_data_size); void undo_history_pop(UndoHistory *undo_history); static inline int undo_history_empty(UndoHistory *undo_history) { return undo_history->actions.count == 0; } #endif // UNDO_HISTORY_H_