Did you know ... | Search Documentation: |
![]() | Accessing blobs |
The blob access functions are similar to the atom accessing functions. Blobs being atoms, the atom functions operate on blobs and vice versa. For clarity and possible future compatibility issues, however, it is not advised to rely on this.
PL_BLOB_UNIQUE
set, search
the blob database for a blob of the same type with the same content. If
found, unify t with the existing handle.PL_BLOB_UNIQUE
is not set, create a new
blob handle. If PL_BLOB_NOCOPY
is set, associate it to the
given memory; else, copy the memory to a new area owned by the blob.
Call the acquire()
function of the type.It is possible that a blob referencing critial resources is created after which the unification fails. Typically these resources are eventually reclaimed because the new blob is not referenced and reclaimed by the atom garbage collector. As described with the release() function, it can be desirable to reclaim the critical resources after the failing PL_unify_blob() call.
FALSE
) or the blob is a
reference to an existing blob (TRUE
). Reporting
new/existing can be used to deal with external objects having their own
reference counts. If the return is TRUE
this reference
count must be incremented, and it must be decremented on blob
destruction callback. See also
PL_put_atom_nchars().TRUE
. Otherwise return FALSE
. Each result
pointer may be NULL
, in which case the requested
information is ignored.
Get the data and type associated to a blob. This function is mainly
used from the callback functions described in section
12.4.10.1. Note that if the release() hook is called from PL_cleanup(),
blobs are released regardless of whether or not they are referenced and
the order in which blobs are released is undefined (the order depends on
the ordering in the atom hash table). PL_blob_data()
may be called safely on a blob that has already been released. If this
happens during PL_cleanup()
the return value is guaranteed to be NULL
. During normal
execution it may return the content of a newly allocated blob that
reuses the released handle.
PL_BLOB_NOCOPY
flag set and a release() function. It causes
the release() function to be called, after which the data and size are
set to 0. The related atom remains existent and accessing it as a blob
returns NULL
for the data and 0 for the size.