[Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

Francisco Jerez currojerez at riseup.net
Wed Feb 11 09:16:20 PST 2015

Matt Turner <mattst88 at gmail.com> writes:

> On Wed, Feb 11, 2015 at 6:37 AM, Juha-Pekka Heikkila
> <juhapekka.heikkila at gmail.com> wrote:
>> There is no error path available thus instead of giving
>> realloc possibility to fail use new which will never
>> return null pointer and throws bad_alloc on failure.
> The problem was that we weren't checking if realloc failed.
> Why is the solution to change from malloc/free to new/delete?

The new operator is guaranteed not to return NULL by the C++ standard.
Aside from that Juha-Pekka's code seems more idiomatic to me than
calling realloc() from a C++ source file, but that might just be a
matter of taste.

> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150211/3bf4fd2a/attachment.sig>

More information about the mesa-dev mailing list