Added tons of documentation headers to functions in source files.

This commit is contained in:
Johannes Findeisen 2026-10-27 01:58:27 +01:00
commit 4eb2080933
43 changed files with 3953 additions and 43 deletions

View file

@ -10,6 +10,12 @@ struct xtc_history {
size_t next_node;
};
/**
* @brief Raises history's identifier high-water marks to include the project's allocations.
*
* @param h Snapshot history handle.
* @param p Project model; borrowed for this call.
*/
static void remember_ids(xtc_history *h, const xtc_project *p)
{
if (p->next_track_id > h->next_track)
@ -22,6 +28,11 @@ static void remember_ids(xtc_history *h, const xtc_project *p)
h->next_node = p->graph->next_id;
}
/**
* @brief Releases all retained snapshots and history storage; accepts NULL.
*
* @param h Snapshot history handle.
*/
void xtc_history_destroy(xtc_history *h)
{
size_t i;
@ -32,6 +43,13 @@ void xtc_history_destroy(xtc_history *h)
free(h);
}
/**
* @brief Creates snapshot history with an independent copy of the initial project.
*
* @param p Project model; borrowed for this call.
* @param out Receives the newly allocated object; caller owns it on success.
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_history_create(const xtc_project *p, xtc_history **out)
{
xtc_history *h;
@ -55,6 +73,13 @@ xtc_result xtc_history_create(const xtc_project *p, xtc_history **out)
return XTC_OK;
}
/**
* @brief Appends a project snapshot, discarding redo states and evicting the oldest state if full.
*
* @param h Snapshot history handle.
* @param p Project model; borrowed for this call.
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_history_record(xtc_history *h, const xtc_project *p)
{
xtc_project *copy;
@ -79,11 +104,26 @@ xtc_result xtc_history_record(xtc_history *h, const xtc_project *p)
return XTC_OK;
}
/**
* @brief Checks whether an adjacent undo or redo snapshot exists.
*
* @param h Snapshot history handle.
* @param redo Zero for undo, one for redo.
* @return Nonzero when the requested history state exists, zero otherwise.
*/
static int available(const xtc_history *h, int redo)
{
return redo ? h->cursor + 1 < h->count : h->cursor > 0;
}
/**
* @brief Clones the adjacent undo or redo state without moving the history cursor.
*
* @param h Snapshot history handle.
* @param redo Zero for undo, one for redo.
* @param out Receives the newly allocated object; caller owns it on success.
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_history_checkout(const xtc_history *h, int redo, xtc_project **out)
{
if (!out)
@ -105,6 +145,13 @@ xtc_result xtc_history_checkout(const xtc_history *h, int redo, xtc_project **ou
}
}
/**
* @brief Moves the history cursor after the checked-out project has been installed.
*
* @param h Snapshot history handle.
* @param redo Zero for undo, one for redo.
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_history_accept(xtc_history *h, int redo)
{
if (!h || (redo != 0 && redo != 1))