change palloc to malloc

Started by Nguyen Haialmost 21 years ago3 messages
#1Nguyen Hai
nguyen_hai91@yahoo.com

Hi,

Is it possible to convert palloc back to malloc?
If so, what should I do to make the change?

Many Thanks,
Hai

__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/

#2Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Nguyen Hai (#1)
Re: change palloc to malloc

Nguyen Hai wrote:

Hi,

Is it possible to convert palloc back to malloc?
If so, what should I do to make the change?

You can, but palloc is automatically freed at the end of a query, while
malloc has to be freed in the code. Why do you want to make the
switch?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Karel Zak
zakkr@zf.jcu.cz
In reply to: Bruce Momjian (#2)
Re: change palloc to malloc

On Tue, 2005-03-15 at 18:29 -0500, Bruce Momjian wrote:

Nguyen Hai wrote:

Hi,

Is it possible to convert palloc back to malloc?
If so, what should I do to make the change?

You can, but palloc is automatically freed at the end of a query, while
malloc has to be freed in the code. Why do you want to make the
switch?

Right. And it's definitely faster use palloc() than malloc(). I think
the current code is really based on memory contexts and I'm sure that
(strange:-) s/palloc/malloc/ is not enough.

Karel
--
Karel Zak <zakkr@zf.jcu.cz>