[fpc-devel] MemSize argument validity

Nikolai Zhubr n-a-zhubr at yandex.ru
Wed Feb 17 17:59:25 CET 2010


17.02.2010 13:35, Marco van de Voort:
> In our previous episode, Jonas Maebe said:
>>> I've just discovered that passing an invalid pointer to MemSize()
>>> results in a bogus value returned and no error generally reported.
>>> Is this intentional?
>>
>> It's just as intentional as dereferencing an invalid pointer can
>> result in a segmentation fault, that freemem'ing an invalid pointer
>> can corrupt the heap, etc. It's how manual memory management works:
>> the programmer is responsible for not making any errors with pointers.
>
> ... and that means assuming that you can't make out failsafe if a pointer is
> valid or not. One needs to manage that oneself.

Ok, thanks. I just hoped MemSize could be magically different from others :)

Nikolai

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




More information about the fpc-devel mailing list