refc_binary.c
Include dependency graph for refc_binary.c:
![digraph {
graph [bgcolor="#00000000"]
node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
edge [color="#1414CE"]
"4" [label="stdbool.h" tooltip="stdbool.h"]
"27" [label="dictionary.h" tooltip="dictionary.h"]
"18" [label="atom.h" tooltip="atom.h"]
"30" [label="trace.h" tooltip="trace.h"]
"9" [label="assert.h" tooltip="assert.h"]
"22" [label="synclist.h" tooltip="synclist.h"]
"29" [label="tempstack.h" tooltip="tempstack.h"]
"12" [label="stdint.h" tooltip="stdint.h"]
"2" [label="stdlib.h" tooltip="stdlib.h"]
"16" [label="context.h" tooltip="context.h"]
"14" [label="utils.h" tooltip="utils.h"]
"19" [label="atom_table.h" tooltip="atom_table.h"]
"8" [label="term_typedef.h" tooltip="term_typedef.h"]
"15" [label="stddef.h" tooltip="stddef.h"]
"10" [label="limits.h" tooltip="limits.h"]
"1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/refc_binary.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/refc_binary.c" fillcolor="#BFBFBF"]
"3" [label="refc_binary.h" tooltip="refc_binary.h"]
"25" [label="string.h" tooltip="string.h"]
"20" [label="mailbox.h" tooltip="mailbox.h"]
"24" [label="term.h" tooltip="term.h"]
"7" [label="erl_nif.h" tooltip="erl_nif.h"]
"6" [label="resources.h" tooltip="resources.h"]
"21" [label="smp.h" tooltip="smp.h"]
"28" [label="erl_nif_priv.h" tooltip="erl_nif_priv.h"]
"17" [label="globalcontext.h" tooltip="globalcontext.h"]
"13" [label="memory.h" tooltip="memory.h"]
"23" [label="stdio.h" tooltip="stdio.h"]
"26" [label="timer_list.h" tooltip="timer_list.h"]
"11" [label="inttypes.h" tooltip="inttypes.h"]
"5" [label="list.h" tooltip="list.h"]
"27" -> "5" [dir=forward tooltip="include"]
"27" -> "24" [dir=forward tooltip="include"]
"18" -> "12" [dir=forward tooltip="include"]
"18" -> "2" [dir=forward tooltip="include"]
"22" -> "5" [dir=forward tooltip="include"]
"22" -> "23" [dir=forward tooltip="include"]
"22" -> "21" [dir=forward tooltip="include"]
"29" -> "8" [dir=forward tooltip="include"]
"29" -> "14" [dir=forward tooltip="include"]
"16" -> "17" [dir=forward tooltip="include"]
"16" -> "5" [dir=forward tooltip="include"]
"16" -> "20" [dir=forward tooltip="include"]
"16" -> "21" [dir=forward tooltip="include"]
"16" -> "24" [dir=forward tooltip="include"]
"16" -> "26" [dir=forward tooltip="include"]
"14" -> "15" [dir=forward tooltip="include"]
"19" -> "4" [dir=forward tooltip="include"]
"19" -> "18" [dir=forward tooltip="include"]
"8" -> "9" [dir=forward tooltip="include"]
"8" -> "10" [dir=forward tooltip="include"]
"8" -> "11" [dir=forward tooltip="include"]
"8" -> "12" [dir=forward tooltip="include"]
"1" -> "2" [dir=forward tooltip="include"]
"1" -> "3" [dir=forward tooltip="include"]
"1" -> "16" [dir=forward tooltip="include"]
"1" -> "27" [dir=forward tooltip="include"]
"1" -> "28" [dir=forward tooltip="include"]
"1" -> "13" [dir=forward tooltip="include"]
"1" -> "29" [dir=forward tooltip="include"]
"1" -> "14" [dir=forward tooltip="include"]
"1" -> "30" [dir=forward tooltip="include"]
"3" -> "4" [dir=forward tooltip="include"]
"3" -> "2" [dir=forward tooltip="include"]
"3" -> "5" [dir=forward tooltip="include"]
"3" -> "6" [dir=forward tooltip="include"]
"20" -> "4" [dir=forward tooltip="include"]
"20" -> "5" [dir=forward tooltip="include"]
"20" -> "8" [dir=forward tooltip="include"]
"20" -> "14" [dir=forward tooltip="include"]
"24" -> "4" [dir=forward tooltip="include"]
"24" -> "12" [dir=forward tooltip="include"]
"24" -> "23" [dir=forward tooltip="include"]
"24" -> "2" [dir=forward tooltip="include"]
"24" -> "25" [dir=forward tooltip="include"]
"24" -> "13" [dir=forward tooltip="include"]
"24" -> "3" [dir=forward tooltip="include"]
"24" -> "14" [dir=forward tooltip="include"]
"24" -> "8" [dir=forward tooltip="include"]
"7" -> "8" [dir=forward tooltip="include"]
"6" -> "2" [dir=forward tooltip="include"]
"6" -> "7" [dir=forward tooltip="include"]
"6" -> "5" [dir=forward tooltip="include"]
"6" -> "13" [dir=forward tooltip="include"]
"21" -> "4" [dir=forward tooltip="include"]
"28" -> "16" [dir=forward tooltip="include"]
"28" -> "13" [dir=forward tooltip="include"]
"17" -> "12" [dir=forward tooltip="include"]
"17" -> "18" [dir=forward tooltip="include"]
"17" -> "19" [dir=forward tooltip="include"]
"17" -> "7" [dir=forward tooltip="include"]
"17" -> "5" [dir=forward tooltip="include"]
"17" -> "20" [dir=forward tooltip="include"]
"17" -> "21" [dir=forward tooltip="include"]
"17" -> "22" [dir=forward tooltip="include"]
"17" -> "24" [dir=forward tooltip="include"]
"17" -> "26" [dir=forward tooltip="include"]
"13" -> "7" [dir=forward tooltip="include"]
"13" -> "8" [dir=forward tooltip="include"]
"13" -> "14" [dir=forward tooltip="include"]
"13" -> "12" [dir=forward tooltip="include"]
"13" -> "2" [dir=forward tooltip="include"]
"26" -> "4" [dir=forward tooltip="include"]
"26" -> "12" [dir=forward tooltip="include"]
"26" -> "5" [dir=forward tooltip="include"]
}](../../../_images/graphviz-74746e3bf053246ca6f3a2e46b321a9fc3aaa64d.png)
Functions
-
struct RefcBinary *refc_binary_create_resource(size_t size, struct ResourceType *resource_type)
Create a reference-counted resource object outside of the process heap.
This function will create a reference-counted resource object outside of the context heap. A blob will be allocated in the VM memory (e.g., via malloc). The allocated data will include an internal data structure that includes the data size and reference count.
- Parameters:
size – the size of the data to create
resource_type – the resource type,
NULL
for regular refc binaries.
- Returns:
a pointer to the out-of-context data.
-
const char *refc_binary_get_data(const struct RefcBinary *refc)
get the data of the off-context binary
Return the data of the off-context binary
- Parameters:
ptr – Refc binary returned from memory_create_refc_binary
-
struct RefcBinary *refc_binary_from_data(void *ptr)
get the refc binary from its pointer
This must only be passed the result of
refc_binary_get_data
.- Parameters:
ptr – pointer obtained from
refc_binary_get_data
-
void refc_binary_increment_refcount(struct RefcBinary *refc)
Increment the reference count on the refc binary.
- Parameters:
ptr – the refc binary
-
bool refc_binary_decrement_refcount(struct RefcBinary *refc, struct GlobalContext *global)
Decrement the reference count on the refc binary.
This function will call
refc_binary_destroy
if the reference count reaches 0.- Parameters:
ptr – the refc binary
global – the global context
- Returns:
true if the refc binary was free’d; false, otherwise
-
void refc_binary_destroy(struct RefcBinary *refc, struct GlobalContext *global)
Destroy a refc binary after its reference count reached 0.
This function will call the destructor if the refc binary is a resource and will free the refc binary.
- Parameters:
refc – the binary to destroy
global – the global context