[Development] QtCore missing check for memory allocation

Marc Mutz marc.mutz at kdab.com
Wed Feb 25 21:21:10 CET 2015


On Wednesday 25 February 2015 17:36:39 Mathias Hasselmann wrote:
[...]
> Writing allocation-safe code was considering a good idea years ago.
> Sadly the people supporting that approach totally forgot that checking
> each memory allocation dramatically inflates cyclomatic complexity of
> your code, rendering it unmaintainable quickly. Have a look at libdbus
> to get an idea of the overhead allocation-safe code causes.

libdbus is written in an inferior language. In C++, it is good practice to 
write exception-safe code anyway, and then it doesn't really matter that any 
statement may throw: the code stays elegant and robust _because_ you assume 
any statment can throw unless proven otherwise.

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions



More information about the Development mailing list