[fpc-pascal] length for long ansistring = segment fault

ik idokan at gmail.com
Mon Dec 3 17:47:45 CET 2012


On Mon, Dec 3, 2012 at 1:00 PM, Michael Van Canneyt
<michael at freepascal.org> wrote:
>
>
> On Mon, 3 Dec 2012, Jonas Maebe wrote:
>
>>
>> On 03 Dec 2012, at 11:52, Michael Van Canneyt wrote:
>>
>>> On Mon, 3 Dec 2012, Jonas Maebe wrote:
>>>
>>>> On 03 Dec 2012, at 11:13, Michael Van Canneyt wrote:
>>>>
>>>>> You are overwriting the pointer. S is (behind the scenes) a pointer to
>>>>> a memory area. You should do FillChar(s[1], 1024, '*');
>>>>
>>>>
>>>> Or use http://www.freepascal.org/docs-html/rtl/system/stringofchar.html
>>>
>>>
>>> I was considering answering with that too, but I didn't feel like
>>> checking how it is implemented, to judge the speed penalty :)
>>
>>
>> It definitely doesn't have the "ask the mailing list because I made a
>> mistake"-penalty :)
>
>
> Checked anyway now. Stringofchar uses fillchar internally, so it's better to
> use that.

I completely forgot about it, if I would remember it, I would have
used it in the first place

>
> Michael.
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list