summaryrefslogtreecommitdiff
path: root/malloc/my_recycler/recycler.h
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /malloc/my_recycler/recycler.h
add: added projectsHEADmain
Diffstat (limited to 'malloc/my_recycler/recycler.h')
-rw-r--r--malloc/my_recycler/recycler.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/malloc/my_recycler/recycler.h b/malloc/my_recycler/recycler.h
new file mode 100644
index 0000000..bff70ef
--- /dev/null
+++ b/malloc/my_recycler/recycler.h
@@ -0,0 +1,24 @@
+#ifndef RECYCLER_H
+#define RECYCLER_H
+
+#include <stddef.h>
+
+struct recycler
+{
+ size_t block_size;
+ size_t capacity; // number of blocks in the chunk
+ void *chunk; // memory chunk containing all blocks
+ void *free; // address of the first free block of the free list
+};
+
+struct free_list
+{
+ struct free_list *next; // next free block
+};
+
+struct recycler *recycler_create(size_t block_size, size_t total_size);
+void recycler_destroy(struct recycler *r);
+void *recycler_allocate(struct recycler *r);
+void recycler_free(struct recycler *r, void *block);
+
+#endif /* !RECYCLER_H */