From: | Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | scrappy(at)hub(dot)org (The Hermit Hacker) |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] palloc() vs static define? |
Date: | 1998-12-14 04:01:27 |
Message-ID: | 199812140401.XAA06755@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>
> in commands/cluster.c, in function cluster, we define NewIndexName as:
>
> char NewIndexName[NAMEDATALEN]; /* line 93 */
>
> in function copy_index, we define it as:
>
> char *NewIndexName; /* line 246 */
>
> And then palloc(NAMEDATALEN) before it gets used...
>
> Now, which we use doesn't much matter to me, but I would think some sort
> of consistency would be in order...or am I missing something as far as
> each are concerned? Is one method inheriently faster then another, or do
> they have about the same performance characteristics?
Uh, O, Marc is coding. :-)
cluster.c was written by a hack, and has been cleaned up over time. You
can use either method.
> char NewIndexName[NAMEDATALEN]; /* line 93 */
Allocated stack space on function entry, and releases it on function
exit.
> And then palloc(NAMEDATALEN) before it gets used...
palloc() allocates at function call time, and you have to pfree it, or
wait for transaction to pfree it. If you are starting/stopping
transactions between palloc() and pfree() you could loose the memory
unless you change to the 'cache' memory context before doing the palloc
and pfree. See other command/*.c files for examples of this.
--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 1998-12-14 04:02:17 | Re: [HACKERS] Please check: commands/dbcommands.c |
Previous Message | Bruce Momjian | 1998-12-14 03:58:32 | Re: [HACKERS] Can't 'or' things? |