Thread: oid2name cleanup

oid2name cleanup

From
Neil Conway
Date:
Currently, contrib/oid2name doesn't bother to free() the memory that it
malloc()'s. This isn't too serious (because oid2name is a short-lived
utility, so the memory will soon be returned to the OS on process
termination), but I still think it's poor style.

This patch changes oid2name so that it allocates memory on the stack
where possible and free()s the remaining heap-allocated memory. The
patch also fixes a typo a comment and adds 'const' qualifiers to a few
'char *' function parameters.

Cheers,

Neil

--
Neil Conway <neilconway@rogers.com>
PGP Key ID: DB3C29FC

Attachment

Re: oid2name cleanup

From
Bruce Momjian
Date:
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


Neil Conway wrote:
> Currently, contrib/oid2name doesn't bother to free() the memory that it
> malloc()'s. This isn't too serious (because oid2name is a short-lived
> utility, so the memory will soon be returned to the OS on process
> termination), but I still think it's poor style.
>
> This patch changes oid2name so that it allocates memory on the stack
> where possible and free()s the remaining heap-allocated memory. The
> patch also fixes a typo a comment and adds 'const' qualifiers to a few
> 'char *' function parameters.
>
> Cheers,
>
> Neil
>
> --
> Neil Conway <neilconway@rogers.com>
> PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: oid2name cleanup

From
Bruce Momjian
Date:
Patch applied.  Thanks.

---------------------------------------------------------------------------


Neil Conway wrote:
> Currently, contrib/oid2name doesn't bother to free() the memory that it
> malloc()'s. This isn't too serious (because oid2name is a short-lived
> utility, so the memory will soon be returned to the OS on process
> termination), but I still think it's poor style.
>
> This patch changes oid2name so that it allocates memory on the stack
> where possible and free()s the remaining heap-allocated memory. The
> patch also fixes a typo a comment and adds 'const' qualifiers to a few
> 'char *' function parameters.
>
> Cheers,
>
> Neil
>
> --
> Neil Conway <neilconway@rogers.com>
> PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026