Am 01.07.2014 20:59 schrieb "Jonas Maebe" <jonas.ma...@elis.ugent.be>:
>
> On 01/07/14 19:42, Paul Breneman wrote:
>>
>> I'm doing the same thing in FPC and D7:
>>        StringLen := 14;
>>        MyReturnStr := 'test1234567890';
>>        Status := ps5000aGetUnitInfo( ps5000a_handle, @MyReturnStr[ 0],
>> StringLen, requiredSize, RInfo);
>
>
> It wrong in both FPC and D7 (and it will also crash on all platforms in
the next version of FPC; in the current version, it will only crash on OS
X). You are assigning a string constant to a pchar, and then telling the
DLL to overwrite it.
>
> In current release versions of FPC (where it doesn't crash), that will
result in the data of that string constant getting overwritten. This means
that if you assign 'test1234567890' somewhere else to a string, that string
will actually get the value with which this string was overwritten the last
time.
>
> Use getmem to allocate writeable memory.

In case MyReturnStr is a Ansi-, Wide- or UnicodeString shouldn't
"SetLength(MyReturnStr, StringLen)" work as well?

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to