Re: libpq docs about PQfreemem - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: libpq docs about PQfreemem
Date
Msg-id 200702192206.l1JM6SB29214@momjian.us
Whole thread Raw
In response to Re: libpq docs about PQfreemem  ("Zeugswetter Andreas ADI SD" <ZeugswetterA@spardat.at>)
List pgsql-hackers
I have updated the PQfree documentation;  patch attached.  Backpatched
to 8.2.X.

---------------------------------------------------------------------------

Zeugswetter Andreas ADI SD wrote:
>
> > > future for some reason. (the doc for the other functions say you
> have to
> > > use PQfreemem without mentioning any exceptions)
> > >
> > > Thoughts? Rip out or update?
> >
> > Are you saying that almost all Win32 binaries and libraries now can
> free
> > across DLLs?
>
> You can under very narrow conditions. You need to force code generation
> for "Multithreaded DLL" run-time libraries (e.g. in VC6 msvcrt.dll)
> for all exe's and dll's.
> This is bad for debugging, memory checkers and probably impossible
> when using different compilers.
> So you really need PQfreemem.
>
> Andreas

--
  Bruce Momjian  <bruce@momjian.us>          http://momjian.us
  EnterpriseDB                               http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/libpq.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v
retrieving revision 1.231
diff -c -c -r1.231 libpq.sgml
*** doc/src/sgml/libpq.sgml    16 Feb 2007 16:37:29 -0000    1.231
--- doc/src/sgml/libpq.sgml    19 Feb 2007 22:04:28 -0000
***************
*** 2617,2625 ****
     <function>PQescapeBytea</function>,
     <function>PQunescapeBytea</function>,
     and <function>PQnotifies</function>.
!    It is needed by Microsoft Windows, which cannot free memory across
!    DLLs, unless multithreaded DLLs (<option>/MD</option> in VC6) are used.
!    On other platforms, this function is the same as the standard library function <function>free()</>.
    </para>
    </listitem>
    </varlistentry>
--- 2617,2629 ----
     <function>PQescapeBytea</function>,
     <function>PQunescapeBytea</function>,
     and <function>PQnotifies</function>.
!    It is particularly important that this function, rather than
!    <function>free()</>, be used on Microsoft Windows.  This is because
!    allocating memory in a DLL and releasing it in the application works
!    only if multithreaded/single-threaded, release/debug, and static/dynamic
!    flags are the same for the DLL and the application.  On non-Microsoft
!    Windows platforms, this function is the same as the standard library
!    function <function>free()</>.
    </para>
    </listitem>
    </varlistentry>

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Proposed adjustments in MaxTupleSize andtoastthresholds
Next
From: Jakub Ouhrabka
Date:
Subject: Re: Howto change db cluster locale on-the-fly