[fpc-pascal] Re: Access violation that I do not understand while creating a class instance

ik idokan at gmail.com
Mon Jan 23 16:38:48 CET 2012


On Mon, Jan 23, 2012 at 17:10, Henry Vermaak <henry.vermaak at gmail.com>wrote:

> On 23/01/12 14:56, ik wrote:
>
>> On Mon, Jan 23, 2012 at 16:28, ik <idokan at gmail.com
>> <mailto:idokan at gmail.com>> wrote:
>>
>>    Hello,
>>
>>    In the following code
>>    (https://github.com/ik5/redit_**client.fpc/blob/master/tests/**
>> test_parser.lpr#L55<https://github.com/ik5/redit_client.fpc/blob/master/tests/test_parser.lpr#L55>
>> ),
>>
>>    when I point, I have access violation when trying to create
>>    TRedisErrorReturnType.Create
>>
>>    It does not happen for TRedisStatusReturnType.Create for example,
>>    that have the same parent as TRedisErrorReturnType.
>>
>>    What am I missing or doing wrong here ?
>>
>>
>> Solved it, but I do not understand it.
>> Why did new made access violation and StrAlloc not ?
>>
>
> Because new() just allocated one pchar and not a buffer.  Why do you think
> using a pchar like this is faster than using string?  Have you benchmarked
> it?
>

I haven't benchmark anything in my life :)
PChar is an array like approach. AnsiString, is a record based pointer. It
uses more memory, and provide a bit overhead for the same thing.
At least on theory. I would love to learn that it's not the case.

Thanks


>
> Henry
> ______________________________**_________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.**org<fpc-pascal at lists.freepascal.org>
> http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal>
>

Ido
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20120123/ac775784/attachment.html>


More information about the fpc-pascal mailing list