rt: Add constructors and destructors for stacks
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
#ifndef RUST_STACK_H
|
||||
#define RUST_STACK_H
|
||||
|
||||
struct stk_seg {
|
||||
stk_seg *prev;
|
||||
stk_seg *next;
|
||||
@@ -10,6 +13,19 @@ struct stk_seg {
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
template <class T>
|
||||
stk_seg *
|
||||
create_stack(T allocer, size_t sz) {
|
||||
size_t total_sz = sizeof(stk_seg) + sz;
|
||||
return (stk_seg *)allocer->malloc(total_sz, "stack");
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
destroy_stack(T allocer, stk_seg *stk) {
|
||||
allocer->free(stk);
|
||||
}
|
||||
|
||||
void
|
||||
config_valgrind_stack(stk_seg *stk);
|
||||
|
||||
@@ -21,3 +37,5 @@ add_stack_canary(stk_seg *stk);
|
||||
|
||||
void
|
||||
check_stack_canary(stk_seg *stk);
|
||||
|
||||
#endif /* RUST_STACK_H */
|
||||
|
||||
Reference in New Issue
Block a user