20-queue-and-stack/stack.c
github-classroom[bot] e6e6f4ae94
Initial commit
2025-04-01 10:41:03 +00:00

42 lines
1.4 KiB
C

/*----------------------------------------------------------
* HTBLA-Leonding / Class: <your class>
* ---------------------------------------------------------
* Exercise Number: S03
* Title: Stack implementation
* Author: */<your name>;/*
* ----------------------------------------------------------
* Description:
* Implementation of a stack based on an advanced singly linked list.
* ----------------------------------------------------------
*/
/*
Implementation notes:
1) The 'StackData' struct SHALL encapsulate the underlying list
to decouple stack and stack interfaces. No further members are required.
2) Stack allocation:
Use functions `mem_alloc(…)` and `mem_free(…)`
declared in `allocator.h`. DO NOT use `malloc(…)` and `free(…)` directly
as unit tests will fail.
3) Avoid code duplication wherever (reasonably) possible.
The implemenation of each function mostly delegates
to the corresponding stack function (one-liners).
Implement the combined functionality of 'pop' and 'peek'
as a single private function which is used by 'pop' and 'peek'.
*/
/* includes */
/** The implementation of stack data */
/* ===================================================================== */
/* private stack functions */
/* ===================================================================== */