move(somepchar^,pchar(ansi_str_dest)^,len);

doesn't check fpc_ansistr_unique. So it works only if ansi_str_dest has only one reference; or both strings will be modified (because no copy-on-write happens).

At least, that's what I get to see, if I compile with -al and look at the assembler.

JoshyFun wrote:
Hello Martin,

Monday, May 12, 2008, 11:27:08 PM, you wrote:

MF> Hi,
MF> I am trying to find some info on how I can use move to archive the
MF> following:
MF> I am looking for an equal replacement of
MF> move(somepchar^, ansi_str_dest[1], len)
[...]
MF> I could prefix it with "if length(dest) > 0 then ", but I would prefer
MF> something less noticeable...

I had not checked it but I think you can use the typecasting:

move(somepchar^,pchar(ansi_str_dest)^,len);

as typecasting an ansistring to a pchar should return (repeat "I
think") a pointer to ansi_str_dest[1], and if length(ansi_str_dest)=0
then the pointer should be $00000001 :-? which should not raise any
kind of range check.

_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to