Subject Re: Database grows rapidly (3 to 770MB) when using BLOB views/UDFs
Author mircostange
The UDF is written in C (actually C++ with VC). It tried to extract
the relevant pieces.

The function is defined as
__declspec(dllexport) void ProPXMakeBitmap(
double *scaleFactor,

As you see, it takes a BLOB b, a scaleFactor and also a handle to the
BLOB to be returned. As I understood, this is how the signature is
supposed to look like for BLOB UDFs, i.e. there is an additional
param for the return BLOB.

The UDF then reads data from the source BLOB, e.g.

while ((*b->blob_get_segment) (b->blob_handle, tmp, b->max_seglen ,
tmp += length;

Then it does the transformation

char *buf2 = makePicture(..., tmp, ...);

And writes the data into "ret"

bool done = false;
long rest = len;
long pos = 0;
while (!done)
long chunksize = b->max_seglen;
if (rest < b->max_seglen )
chunksize = rest;

(*ret->blob_put_segment) (ret->blob_handle, buf2+pos,
pos += chunksize;
rest -= chunksize;

if (rest <= 0)
done = true;

Finally, temp memory is freed and the function returns.

Anything wrong with this? Do I have to call some function to tell
Firebird that this BLOB is temporary?