Re: question on how to correctly communicate with external library functions which return malloc()'ed strings

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Vladimir Volovich <vvv(at)vsu(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: question on how to correctly communicate with external library functions which return malloc()'ed strings
Date: 2008-04-11 09:48:46
Message-ID: 20080411094845.GC23648@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 10, 2008 at 07:28:29PM -0700, Vladimir Volovich wrote:
> it worked fine with postgresql 8.2; with 8.3 it started segfaulting, and
> it appeared that the reason is because in postgresql 8.3, the "free" is
> a macro defined in
> snowball/header.h:
> #define free(a) pfree(a)

It does seem wrong. Do you include that header file explicitly? Because
it shouldn't be necessary.

> #ifdef free
> #warning undefining free
> #undef free
> #endif
> #include <stdlib.h>
>
> but i want to ask you, postgresql hackers, on how we are supposed to
> work with external library functions which return malloc()'ed strings?

See if you can avoid including that header altogether...

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2008-04-11 09:57:20 Re: Separate psql commands from arguments
Previous Message Bernd Helmle 2008-04-11 09:38:28 Re: Separate psql commands from arguments