File tree Expand file tree Collapse file tree 1 file changed +29
-3
lines changed
Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change 77extern "C"
88{
99#endif
10+ /**
11+ * @enum block_state
12+ * @brief Enumeration of block states in the memory allocator.
13+ *
14+ * This enum defines the possible states of a memory block in the
15+ * kernel memory allocator.
16+ */
17+ enum block_state {
18+ BLOCK_FREE = 0 , /**< Block is free and available for allocation. */
19+ BLOCK_USED /**< Block is currently allocated and in use. */
20+ };
1021
11- void kmalloc_init (void * start , void * limit );
12- void * kmalloc (size_t size );
13- size_t kmalloc_remaining (void );
22+ /**
23+ * @brief Header structure for memory blocks in the allocator.
24+ *
25+ * Each allocated or free block in the kernel memory allocator is
26+ * preceded by a header that contains metadata about the block.
27+ */
28+ struct header {
29+ size_t size ; /**< Size of the memory block (excluding header). */
30+ enum block_state state ; /**< State of the block (free or used). */
31+ struct header * next ; /**< Pointer to the next block in the linked list. */
32+ struct header * prev ; /**< Pointer to the previous block in the linked list. */
33+ };
1434
35+ struct header * kmalloc_get_head (void );
36+
37+ void kmalloc_init (void * start , void * limit );
38+ void * kmalloc (size_t size );
39+ void kfree (void * block );
40+ int kmalloc_test (void );
1541#ifdef __cplusplus
1642}
1743#endif
You can’t perform that action at this time.
0 commit comments