From ed33e08dae37a50695a06cb6f3f45f666c6f3b23 Mon Sep 17 00:00:00 2001 From: MarcUs7i Date: Sat, 8 Mar 2025 16:49:22 +0100 Subject: [PATCH] builds now --- mem_man.c | 66 ++++++++++++++++++++++++++++++++++++++++++- mem_man.h | 2 +- mem_man_app.c | 4 +-- mem_man_test_driver.c | 2 +- test_mem_man.c | 2 +- test_mem_man.h | 2 +- 6 files changed, 71 insertions(+), 7 deletions(-) diff --git a/mem_man.c b/mem_man.c index aea5013..f158418 100644 --- a/mem_man.c +++ b/mem_man.c @@ -2,7 +2,7 @@ * HTBLA-Leonding * --------------------------------------------------------- * Title: Simple Memory Manager. - * Author: */;/* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Implementation of a simple memory manager. @@ -29,3 +29,67 @@ */ #define MEMORY_BLOCK_CNT 1024; + + +/** + * Allocates a memory block of the given size in bytes + * in a similar way as `malloc(size)`. + * + * @param size The number of bytes to allocate. + * @return The pointer to the allocated memory block or 0, + * if no memory could be allocated. + */ +void* my_alloc(size_t size) { + return 0; +} + +/** + * Releases the addressed memory block that was allocated via function `my_alloc(...)`. + * If the addressed memory is not allocated, a warning is printed. + * + * @param p The pointer to the memory to free. + */ +void my_free(void* p) { + return; +} + +/** + * Prints a brief statistic report about memory that reveals the following key values: + * # total available memory in bytes. + * # free (not allocated) memory in bytes. + * # used (allocated) memory in bytes + * # free memory in percentage (0 % to 100%) + * # number of allocated units (continuously allocated portions of the memory, not memory blocks) + * # largest free continuous memory unit in bytes. + */ +MemStat mem_get_statistics() { + return (MemStat){0, 0, 0, 0, 0, 0}; +} + +/** + * Prints the allocated units (continuously allocated portions of the memory, not memory blocks) + * including their start address within the managed memory as well as their size + * ordered by their start address. + */ +void mem_print_units() { + return; +} + +/** + * Provides the index of the allocated unit (continuously allocated portions of the memory, not memory blocks) + * the addressed memory belongs to. If the addressed memory is not allocated or the address is outside + * the range of the managed memory, a value less than zero provided. + * + * @param p_mem The pointer to the memory to query. + * @return The unit index the address belongs to or a value less than 0 if the memory is not allocated. + */ +int get_unit_index(void* p_mem) { + return 0; +} + +/** + * Dumps the content of the memory. + */ +void mem_dump() { + return; +} \ No newline at end of file diff --git a/mem_man.h b/mem_man.h index 38a108d..2c956db 100644 --- a/mem_man.h +++ b/mem_man.h @@ -2,7 +2,7 @@ * HTBLA-Leonding * --------------------------------------------------------- * Title: Simple Memory Manager. - * Author: */;/* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Declaration of functions for memory management. diff --git a/mem_man_app.c b/mem_man_app.c index 80040d8..8aec44f 100644 --- a/mem_man_app.c +++ b/mem_man_app.c @@ -2,7 +2,7 @@ * HTBLA-Leonding *----------------------------------------------------------------------------- * Title: Simple Memory Manager. - * Author: */;/* + * Author: Marc Tismonar *----------------------------------------------------------------------------- * Description: * The main application that uses memory manager. @@ -21,5 +21,5 @@ int main(int argc, char *argv[]) { /* Your implementation here. */ - + return 0; } \ No newline at end of file diff --git a/mem_man_test_driver.c b/mem_man_test_driver.c index ecae312..0ba69f5 100644 --- a/mem_man_test_driver.c +++ b/mem_man_test_driver.c @@ -2,7 +2,7 @@ * HTBLA-Leonding * --------------------------------------------------------- * Title: Tests implementation for memory management. - * Author: */;/* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Unit tests for for memory management. diff --git a/test_mem_man.c b/test_mem_man.c index 7633c93..e373042 100644 --- a/test_mem_man.c +++ b/test_mem_man.c @@ -2,7 +2,7 @@ * HTBLA-Leonding * --------------------------------------------------------- * Title: Unit Tests for Memory Manager implementation - * Author: */;/* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Tests functions for memory manager. diff --git a/test_mem_man.h b/test_mem_man.h index 32ab4c0..369a010 100644 --- a/test_mem_man.h +++ b/test_mem_man.h @@ -2,7 +2,7 @@ * HTBLA-Leonding * --------------------------------------------------------- * Title: Unit Tests for Memory Manager implementation - * Author: */;/* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Tests functions for memory manager.