diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 235a8cbc2e24c73b940c3a81a39020106ef0bf27..3c9bc9cd2d7f026c1ccb7cf63ae534ad8d9e4542 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -1,5 +1,5 @@ @@ -1151,6 +1151,25 @@ unsigned char *PQunescapeBytea(const unsigned char *from, size_t *to_length); + + + PQfreemem + + + Frees memory allocated by libpq + +void PQfreemem(void *ptr); + + + + + Frees memory allocated by libpq, particularly + PQescapeBytea and PQunescapeBytea. + It is needed by Win32, which can not free memory across + DLL's, unless multithreaded DLL's (/MD in VC6) are used. + + + diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 878da94cff550248bc5c4514e45fa7b3ae1fca42..5b8a6d3ef04de6478a8ecddbe33469c857106f2d 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.126 2003/03/10 22:28:21 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.127 2003/03/22 03:29:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -284,6 +284,19 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen) 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. * diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 8114d6e78ea7f72d24fbd5e6ee680a028d1fbaa6..ce9132deb4bffa499cb356705d86ed610c95501f 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fe.h,v 1.89 2003/03/20 06:23:30 momjian Exp $ + * $Id: libpq-fe.h,v 1.90 2003/03/22 03:29:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -254,6 +254,7 @@ extern unsigned char *PQescapeBytea(const unsigned char *bintext, size_t binlen, size_t *bytealen); extern unsigned char *PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen); +extern void PQfreemem(void *ptr); /* Simple synchronous query */