refc_binary.c
Include dependency graph for refc_binary.c:
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