It did not change anything, as we are not dereferencing iterator after
delete.

I think changing:
delete *it;
uses.erase(it);

to:
use_info *ptr = *it;
uses.erase(it);
delete ptr;

don't make it more readable or safer, but I can change it if you want to.

On Mon, Jan 30, 2017 at 3:16 PM, Nicolai Hähnle <nhaeh...@gmail.com> wrote:

> Nice find!
>
> On 29.01.2017 19:10, Bartosz Tomczyk wrote:
>
>> ---
>>  src/gallium/drivers/r600/sb/sb_valtable.cpp | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/drivers/r600/sb/sb_valtable.cpp
>> b/src/gallium/drivers/r600/sb/sb_valtable.cpp
>> index a8b7b49cd4..d31a1b76d5 100644
>> --- a/src/gallium/drivers/r600/sb/sb_valtable.cpp
>> +++ b/src/gallium/drivers/r600/sb/sb_valtable.cpp
>> @@ -241,6 +241,7 @@ void value::remove_use(const node *n) {
>>         {
>>                 // TODO assert((*it)->kind == kind) ?
>>                 // TODO assert((*it)->arg == arg) ?
>> +               delete *it;
>>                 uses.erase(it);
>>
>
> The delete should really be after the erase.
>
> Cheers,
> Nicolai
>
>
>         }
>>  }
>> @@ -290,7 +291,12 @@ bool value::is_prealloc() {
>>  }
>>
>>  void value::delete_uses() {
>> -       uses.erase(uses.begin(), uses.end());
>> +       for (uselist::iterator it = uses.begin(); it != uses.end(); ++it)
>> +       {
>> +               delete *it;
>> +       }
>> +
>> +       uses.clear();
>>  }
>>
>>  void ra_constraint::update_values() {
>>
>>
>
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to