Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Commit e1e6fc7

Browse files
author
Mathieu Borderé
authored
Merge pull request #310 from cole-miller/heap-get
heap: Add raft_heap_get
2 parents baac1b6 + 9ffded1 commit e1e6fc7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/raft.h

+13
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,19 @@ RAFT_API void raft_heap_set(struct raft_heap *heap);
10791079
*/
10801080
RAFT_API void raft_heap_set_default(void);
10811081

1082+
/**
1083+
* Return a reference to the current dynamic memory allocator.
1084+
*
1085+
* This is intended for use by applications that want to temporarily replace
1086+
* and then restore the original allocator, or that want to defer to the
1087+
* original allocator in some circumstances.
1088+
*
1089+
* The behavior of attempting to mutate the default allocator through the
1090+
* pointer returned by this function, including attempting to deallocate
1091+
* the backing memory, is undefined.
1092+
*/
1093+
RAFT_API const struct raft_heap *raft_heap_get(void);
1094+
10821095
#undef RAFT__REQUEST
10831096

10841097
#endif /* RAFT_H */

src/heap.c

+5
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,8 @@ void raft_heap_set_default(void)
114114
{
115115
currentHeap = &defaultHeap;
116116
}
117+
118+
const struct raft_heap *raft_heap_get(void)
119+
{
120+
return currentHeap;
121+
}

0 commit comments

Comments
 (0)