Subject Re: [firebird-support] Re: Delphi UDF with PChar
Author Martijn Tonies
> Hi, thanks for your help. I've tried using IBAlloc, but I'm getting
> the same problems as with StrAlloc. It works fine when run in Delphi,
> but when run as a UDF it just outputs a few random characters. Any
> idea what might be going wrong? :-)


Length(InputString), I think, will always return "4" -> that is the
length of the pointer.Try StrLen instead.

Martijn Tonies
Database Workbench - development tool for Firebird and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com

> > > I'm having trouble writing a UDF in Delphi that returns a
> > > PChar. This is a simple example of what I'm trying to do:
> > >
> > > function test(InputString: PChar): PChar; begin
> > > result := StrAlloc(Length(InputString));
> > > StrCopy(result, InputString);
> > > // Presumably the StrAlloc will be freed by the UDF's FREE IT???
> > > end;
> >
> > Shouldn't you use IBMalloc (or similar name) function to allocate
> memory
> > instead of StrAlloc?
>
>
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>