git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: heap support and re-worked
[lunaix-os.git]
/
lunaix-os
/
kernel
/
mm
/
cake.c
diff --git
a/lunaix-os/kernel/mm/cake.c
b/lunaix-os/kernel/mm/cake.c
index 5aa9bef0d97a4e259c9f666431fa71c12a5065fb..5e03d347706c8943b08c9f2792aecb9d7765aad7 100644
(file)
--- a/
lunaix-os/kernel/mm/cake.c
+++ b/
lunaix-os/kernel/mm/cake.c
@@
-120,6
+120,12
@@
cake_new_pile(char* name,
return pile;
}
return pile;
}
+void
+cake_set_constructor(struct cake_pile* pile, pile_cb ctor)
+{
+ pile->ctor = ctor;
+}
+
void*
cake_grab(struct cake_pile* pile)
{
void*
cake_grab(struct cake_pile* pile)
{
@@
-147,8
+153,14
@@
cake_grab(struct cake_pile* pile)
llist_append(&pile->partial, &pos->cakes);
}
llist_append(&pile->partial, &pos->cakes);
}
- return (void*)((uintptr_t)pos->first_piece +
- found_index * pile->piece_size);
+ void* ptr =
+ (void*)((uintptr_t)pos->first_piece + found_index * pile->piece_size);
+
+ if (pile->ctor) {
+ pile->ctor(pile, ptr);
+ }
+
+ return ptr;
}
int
}
int
@@
-188,4
+200,10
@@
found:
}
return 1;
}
return 1;
+}
+
+void
+cake_ctor_zeroing(struct cake_pile* pile, void* piece)
+{
+ memset(piece, 0, pile->piece_size);
}
\ No newline at end of file
}
\ No newline at end of file