In this pattern:
OK, we rarely exhaust HEAP nowadays, and consequences might be catastrophic anyway. aux = realloc( ptr , new_size ); — |
See: 82d1c33#diff-ea77aa3cf89ad27f0980e8a8b857fb1cR585 — |
In reply to this post by David T Lewis
> On 2019-01-01, at 1:39 PM, Nicolas Cellier <[hidden email]> wrote: > > In this pattern: > > ptr = realloc( ptr , new_size ); > > realloc may fail when HEAP memory is exhausted, then return 0, and overwrite ptr with a NULL pointer... > But realloc did not free(ptr), it rather leaves it untouched! That's just... awful. If it can't realloc it should damn well leave the original alone tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Useful random insult:- Not much to show for four billion years of evolution. |
In reply to this post by David T Lewis
Tim, to be sure about understanding: — |
> On 2019-01-02, at 7:12 AM, Nicolas Cellier <[hidden email]> wrote: > > Tim, to be sure about understanding: realloc does the right thing, it leaves the original alone. > It's we, programmers that do not do the right thing: we overwrite a valid pointer with a NULL pointer. Yeah, I thought I had cancelled my email once I realised that was what was going on. Apparently I overwrote the pointer with nil.... tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Strange OpCodes: ESBD: Erase System and Burn Documentation |
Free forum by Nabble | Edit this page |