Re: POC: converting Lists into arrays
От | Oleksandr Shulgin |
---|---|
Тема | Re: POC: converting Lists into arrays |
Дата | |
Msg-id | CACACo5QTvn7JbtJUBXtfb-p3jA6c0pJUk_-4BOHFqokok6m3Rg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: POC: converting Lists into arrays (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: POC: converting Lists into arrays
|
Список | pgsql-hackers |
On Tue, Jul 2, 2019 at 1:27 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
So I think this is a win, and attached is v7.
Not related to the diff v6..v7, but shouldn't we throw additionally a memset() with '\0' before calling pfree():
+
+ newelements = (ListCell *)
+ MemoryContextAlloc(GetMemoryChunkContext(list),
+ new_max_len * sizeof(ListCell));
+ memcpy(newelements, list->elements,
+ list->length * sizeof(ListCell));
+ pfree(list->elements);
+ list->elements = newelements;
Or is this somehow ensured by debug pfree() implementation or does it work differently together with Valgrind?
Otherwise it seems that the calling code can still be hanging onto a list element from a freed chunk and (rather) happily accessing it, as opposed to almost ensured crash if that is zeroed before returning from enlarge_list().
--
Alex
В списке pgsql-hackers по дате отправления: