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

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Wed Feb 11 09:25:10 PST 2015


On 11.02.2015 19:02, Matt Turner wrote:
> 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?
> 

Checking after realloc return value wouldn't help much here because
there is no way to return anything which would indicate 'failed'. The
way this 'allocate' method is used doesn't also help in this case thus
new would throw catchable error instead of just segfaulting or causing
randomness.

/Juha-Pekka


More information about the mesa-dev mailing list