Re: [GENERAL] C Function Memory Management

2012-12-12 Thread Martin French
> Usually I'd allocate the space in fcinfo->flinfo->fn_mcxt (which is a > query-lifespan context) and keep a pointer to it in > fcinfo->flinfo->fn_extra (which is a void * field that a C function > can do what it pleases with). There are plenty of examples in the > Postgres source code. If you ar

Re: [GENERAL] C Function Memory Management

2012-12-12 Thread Tom Lane
Martin French writes: > So out of curiosity, what would be your approach for data preservation > cross call? Usually I'd allocate the space in fcinfo->flinfo->fn_mcxt (which is a query-lifespan context) and keep a pointer to it in fcinfo->flinfo->fn_extra (which is a void * field that a C functi

Re: [GENERAL] C Function Memory Management

2012-12-12 Thread Martin French
> > One thing to know about it is that repalloc re-sizes the given chunk > while keeping it in the same memory context it was originally allocated > in (ie, CurrentMemoryContext doesn't matter). This may not matter much > if you're only dealing with allocations that just live as long as the > cur

Re: [GENERAL] C Function Memory Management

2012-12-12 Thread Tom Lane
Martin French writes: >> repalloc > Maybe I should've looked a little harder for that one! Ha Ha! > I assume it's an exact functional copy of realloc, and see where I get > with it! One thing to know about it is that repalloc re-sizes the given chunk while keeping it in the same memory context

Re: [GENERAL] C Function Memory Management

2012-12-12 Thread Martin French
Hi Pavel > > yes, > > repalloc > Maybe I should've looked a little harder for that one! Ha Ha! I assume it's an exact functional copy of realloc, and see where I get with it! Many Thanks. = Romax Technology Limited Rutherford House Nottingham Sc

Re: [GENERAL] C Function Memory Management

2012-12-12 Thread Pavel Stehule
Hello 2012/12/12 Martin French : > Ok, so just a (hopefully) quick question. > > I know that I should be using the Postgres function palloc in place of > malloc, but what about realloc? Is there an equivalent? yes, repalloc Regards Pavel Stehule > > Thanks. >

[GENERAL] C Function Memory Management

2012-12-12 Thread Martin French
Ok, so just a (hopefully) quick question. I know that I should be using the Postgres function palloc in place of malloc, but what about realloc? Is there an equivalent? Thanks. = Romax Technology Limited Rutherford House Nottingham Science & Technolo