Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
Date: 2022-05-14 21:46:53
Message-ID: CAEudQApCeq4JjW1BdnwU=m=-DvG5WyUik0Yfn3p6UNphiHjj+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

At function load_relcache_init_file, there is an unnecessary function call,
to initialize pgstat_info pointer to NULL.

MemSet(&rel->pgstat_info, 0, sizeof(rel->pgstat_info));

I think that intention with use of MemSet was:
MemSet(&rel->pgstat_info, 0, sizeof(*rel->pgstat_info));

Initialize with sizeof of Struct size, not with sizeof pointer size.
But so it breaks.

Attached a tiny patch.

regards,
Ranier Vilela

Attachment Content-Type Size
avoid_unecessary_memset_call.patch application/octet-stream 486 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andy Fan 2022-05-15 03:11:46 Tracking notnull attributes inside Var
Previous Message Justin Pryzby 2022-05-14 19:26:58 Re: PostgreSQL 15 Beta 1 release announcement draft