[m-users.] Passing blobs over the foreign lanuage interface

Zoltan Somogyi zoltan.somogyi at runbox.com
Sun Feb 12 00:48:45 AEDT 2023


2023-02-12 00:29 GMT+11:00 "Volker Wysk" <post at volker-wysk.de>:
> The right type for a BLOB should be array(uint8).

Logically, a blob corresponds only to the *items* in an array(uint8).
An actual array(uint8) consists of the items *and* the array size.
There is also the issue that Mercury's array type constructor,
being generic, reserves a word of memory for each item.
Not only is this overkill when the items are uint8s, it also means
that the uint8s are not next to each other, which contradicts the
usual definition of a "blob".

The Mercury standard library module that most closely matches
a blob is the bitmap module, though it is more general, as it can also
represent a bit sequence whose length is not a multiple of 8.
Have a look. Note that its C interface is not in the manual either,
but if you have a look at runtime/mercury_types.h and its definition
of MR_BitmapPtr, you should learn all you need to know.

The



More information about the users mailing list