> home > Custom Layer Boundary API

managed_scope_get_attachment

January 19th 2020
Get an attachment contained to a managed scope, allocating it if necessary

Signature

C++
void*
managed_scope_get_attachment(Application_Links* app,
                             Managed_Scope scope,
                             Managed_ID id,
                             u64 size);

Parameters

app

the standard custom layer context pointer

scope

the id of a scope to query

id

the id of the attachment to query

size

the expected size for the attachment, used to allocate memory when the attachment did not previously exist, used to check that the attachment is at least as large as expected if it already exists

Return

a pointer to the base of the attachment when the scope exists and no error ocurred in checking the size of the attachment, zero otherwise

Details

Attachments are allocated on a scopes base allocator, and thus are only valid for as long as the scope itself is valid. Whe in doubt, re-query for an attachment and recheck that the pointer returned is non-zero, as often calls between one usage and another can have an effect on the location or existence of an attachment.