I have modified the patch to call it PQfreemem(), in case there are other
cases we need to free libpq memory.
Patch attached and applied.
---------------------------------------------------------------------------
Zeugswetter Andreas SB SD wrote:
>
> > Actually this isn't even working for me. I just compiled the libpq dll with
> > /MT (multithreaded), and I still get corruption in my app. I even tried
> > libpq compiled with multithreaded-debug (/MTd), which my app is using now,
> > and still same problem.
>
> No, you need to use multithreaded DLL (/MD in VC6) for both the dll and your
> program,
> then it works.
> But since that is not optimal (can't use debug runtime unless you have a second
> debug dll (/MDd)), I also think a callback function would be good to have in
> addition
> to linking libpq.dll with /MD.
>
> Informix e.g. supplies SqlFreeMem( void * MemAddr, int FreeType );
>
> Andreas
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to [EMAIL PROTECTED] so that your
> message can get through to the mailing list cleanly
>
--
Bruce Momjian | http://candle.pha.pa.us
[EMAIL PROTECTED] | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/libpq.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/libpq.sgml,v
retrieving revision 1.113
diff -c -c -r1.113 libpq.sgml
*** doc/src/sgml/libpq.sgml 20 Mar 2003 06:23:30 -0000 1.113
--- doc/src/sgml/libpq.sgml 22 Mar 2003 03:27:47 -0000
***************
*** 1151,1156 ****
--- 1151,1175 ----
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><function>PQfreemem</function></term>
+ <listitem>
+ <para>
+ Frees memory allocated by <application>libpq</>
+ <synopsis>
+ void PQfreemem(void *ptr);
+ </synopsis>
+ </para>
+
+ <para>
+ Frees memory allocated by <application>libpq</>, particularly
+ <function>PQescapeBytea</function> and <function>PQunescapeBytea</function>.
+ It is needed by Win32, which can not free memory across
+ DLL's, unless multithreaded DLL's (/MD in VC6) are used.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</sect2>
Index: src/interfaces/libpq/fe-exec.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-exec.c,v
retrieving revision 1.126
diff -c -c -r1.126 fe-exec.c
*** src/interfaces/libpq/fe-exec.c 10 Mar 2003 22:28:21 -0000 1.126
--- src/interfaces/libpq/fe-exec.c 22 Mar 2003 03:27:53 -0000
***************
*** 284,289 ****
--- 284,302 ----
return buffer;
}
+
+ /*
+ * PQfreemem - safely frees memory allocated
+ *
+ * Needed mostly by Win32, unless multithreaded DLL (/MD in VC6)
+ * Used for freeing memory from PQescapeByte()a/PQunescapeBytea()
+ */
+ void PQfreemem(void *ptr)
+ {
+ free(ptr);
+ }
+
+
/* ----------------
* Space management for PGresult.
*
Index: src/interfaces/libpq/libpq-fe.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/libpq-fe.h,v
retrieving revision 1.89
diff -c -c -r1.89 libpq-fe.h
*** src/interfaces/libpq/libpq-fe.h 20 Mar 2003 06:23:30 -0000 1.89
--- src/interfaces/libpq/libpq-fe.h 22 Mar 2003 03:27:54 -0000
***************
*** 254,259 ****
--- 254,260 ----
size_t *bytealen);
extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
size_t *retbuflen);
+ extern void PQfreemem(void *ptr);
/* Simple synchronous query */
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html