[fpc-devel] MemSize argument validity

Marco van de Voort marcov at stack.nl
Wed Feb 17 11:35:13 CET 2010

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.

More information about the fpc-devel mailing list