Subject RE: [firebird-support] Help needed, gen_uuid() UDF for 2.0
Author Sasha
> Sasha wrote:
> >
> >> Always use ib_util_malloc() to allocate memory for the UDF
> >> result string declared as FREE_IT.
> >
> > I don't know how to do that. Luckily it's weekend ahead and
> I've checked out
> > firebird source... I only wish I knew any c++ ;)
>
> You just need to import ib_util_malloc() from ib_util.dll and
> use this
> function instead of GetMem(). The FB source code won't help
> you much in
> that :-)
>
>
> Dmitry
>
>

Thanx a lot for your help, i finally did it. You were right, fb source code
was not of much help (to me) but it sure was fun :)

If anyone is interested the udf looks like this:

function gen_uuid: PChar; cdecl; export;
var
uid: TGUID;
begin
Result := ib_util_malloc(16);
CreateGUID(uid);
Move(uid, Result^, SizeOf(uid));
end;

and is registered like this:

declare external function gen_uuid returns char(16) character set octets
free_it entry_point 'gen_uuid' module_name 'udf.dll';

Also if anyone is interested Ritchie to wkom I thank also has posted
conversion from uuid to string and vice versa, you can find his post here
http://tech.groups.yahoo.com/group/firebird-support/message/85818

Sasha