[ECOS] Mixed use of delete with malloc in fclose

Guenter Ebermann guenter.ebermann@gmx.at
Sun Jul 20 00:20:00 GMT 2008


Jonathan Larmour wrote:
> I'm not sure I understand the issue. If CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS
> is not defined, then the implementation of delete in libsupc++ should call
> free, just like you say is relevant for your setup.

The theoretical problem would be if operator new and delete would
not use the same memory management as malloc and free does.

> Although I guess you could say the call to delete is 
> redundant - you could always run the code in the 
> CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS block safely.

Yes, the code will be a bit simpler too.
 
> So just so I'm sure I understand it, this patch is not fixing 
> a problem, it's just a bit of cleanup, right?

Its a sort of rule when implementing C++: If new is used delete must be
used. Otherwise if malloc is used free must be used. Mixing these functions
is not allowed.

> When you reply you can provide a ChangeLog entry, thanks :-).

Replaced use of delete with free because memory was allocated using malloc.

    -Guenter


-- 
Psssst! Schon das coole Video vom GMX MultiMessenger gesehen?
Der Eine für Alle: http://www.gmx.net/de/go/messenger03

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list