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

From Martijn van Oosterhout
Subject Re: question on how to correctly communicate with external library functions which return malloc()'ed strings
Date
Msg-id 20080411094845.GC23648@svana.org
Whole thread Raw
In response to question on how to correctly communicate with external library functions which return malloc()'ed strings  (Vladimir Volovich <vvv@vsu.ru>)
Responses Re: question on how to correctly communicate with external library functions which return malloc()'ed strings
List 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@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

pgsql-hackers by date:

Previous
From: Bernd Helmle
Date:
Subject: Re: Separate psql commands from arguments
Next
From: Gregory Stark
Date:
Subject: Re: Separate psql commands from arguments