Disposing generic pointers

Frank Heckenbach ih8mj at fjf.gnu.de
Tue Apr 6 04:49:25 CEST 2010


Jonas Maebe wrote:

> On 05 Apr 2010, at 19:13, John L. Ries wrote:
> 
> > The other day, I compiled a unit I wrote several years ago under FPC and got the following warning:
> > 
> > queues.p(101,37) Warning: use of NEW or DISPOSE for untyped pointers is meaningless
> > 
> > The same unit compiles under GPC (20070904) without warnings.  My question is: does GPC properly deallocate memory in such a case, or is the DISPOSE request ignored?
> 
> Note that FPC also frees memory in this case. It's just that new()
> and dispose() a) are supposed to be used in pairs, but since
> new(pointer) does not really make sense (FPC translates it into
> getmem(p,0) in TP and Delphi modes)

GPC rejects "New (untyped-pointer)". What does TP do?

> b) have
> extended functionality besides freeing memory (such as calling
> constructors/destructors with TP-style objects, and
> initialising/finalising structured types that contain
> reference-counted elements).

Generally I agree that's a good idea (though it makes such an
implementation of "untyped" containers impossible).

However, TP objects don't apply here, since their destructors are
not called automatically (only explicitly with
"Dispose (pointer, destructor (...))"), which I consider a major
drawback of the TP object model, BTW.

Frank

-- 
Frank Heckenbach, f.heckenbach at fh-soft.de, http://fjf.gnu.de/, 7977168E
GPC To-Do list, latest features, fixed bugs:
http://www.gnu-pascal.de/todo.html
GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE  D101 CD02 4C9D 0FE0 E5E8





More information about the Gpc mailing list