[Development] QtCore missing check for memory allocation

Al-Khanji Louai louai.al-khanji at theqtcompany.com
Fri Feb 27 12:15:03 CET 2015


In that case they cannot be overwritten without a recompile. Which brings me back to my original comment from yesterday (to which no one replied):

How is that different from linking a custom implementation of operator new/operator delete and malloc/free into Qt?

These are embedded use-cases anyway, so you wouldn't be using a stock Qt binary.  Implementing the above is well-documented, and in fact both C++11 and C++14 have improved the ways in which the new/delete operators can be overridden.

Just put your implementation in a static lib and pass it to the configure script as an additional library.

On Linux you can also inject such a library using LD_PRELOAD, most operating systems have a similar mechanism. Unlike changing a header, that doesn't require a recompile of Qt.

--Louai


> -----Original Message-----
> From: development-bounces+louai.al-khanji=theqtcompany.com at qt-
> project.org [mailto:development-bounces+louai.al-
> khanji=theqtcompany.com at qt-project.org] On Behalf Of Koehne Kai
> Sent: Friday, February 27, 2015 12:57 PM
> To: Robin Burchell; development at qt-project.org
> Subject: Re: [Development] QtCore missing check for memory allocation
> 
> 
> 
> > -----Original Message-----
> > From: development-bounces+kai.koehne=theqtcompany.com at qt-
> > project.org [mailto:development-
> > bounces+kai.koehne=theqtcompany.com at qt-project.org] On Behalf Of
> > Robin Burchell
> > Sent: Friday, February 27, 2015 11:47 AM
> > To: development at qt-project.org
> > Subject: Re: [Development] QtCore missing check for memory allocation
> >
> > On Fri, Feb 27, 2015 at 9:20 AM, Oswald Buddenhagen
> > <oswald.buddenhagen at theqtcompany.com> wrote:
> > >> The argument is that it implies runtime overhead. See Robin's email
> > >> for numbers. This is asking for making the code slower on the very
> > >> devices where it needs to run faster.
> > >>
> > > i don't trust this number. i don't know how qMalloc was implemented,
> > > but there is no way a simple forwarding wrapper would add 10%
> overhead
> > > to malloc (esp. in an optimized build).
> > > modern processors even have a specific optimization for call
> > > forwarding (or whatever it's called properly).
> 
> qmalloc and friends where implemented in qmalloc.cpp. That is, they can't be
> inlined, and every call to it from another library will be a cross-library one.
> 
> A inlined, header-only wrapper should get away with this.
> 
> Regards
> 
> Kai
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list