• Tom Lane's avatar
    Avoid trying to release a List's initial allocation via repalloc(). · ac12ab06
    Tom Lane authored
    Commit 1cff1b95 included some code that supposed it could repalloc()
    a memory chunk to a smaller size without risk of the chunk moving.
    That was not a great idea, because it depended on undocumented behavior
    of AllocSetRealloc, which commit c477f3e4 changed thereby breaking it.
    (Not to mention that this code ought to work with other memory context
    types, which might not work the same...)  So get rid of the repalloc
    calls, and instead just wipe the now-unused ListCell array and/or tell
    Valgrind it's NOACCESS, as if we'd freed it.
    
    In cases where the initial list allocation had been quite large, this
    could represent an annoying waste of space.  In principle we could
    ameliorate that by allocating the initial cell array separately when
    it exceeds some threshold.  But that would complicate new_list() which
    is hot code, and the returns would materialize only in narrow cases.
    On balance I don't think it'd be worth it.
    
    Discussion: https://postgr.es/m/17059.1570208426@sss.pgh.pa.us
    ac12ab06
list.c 35 KB