From 23ecb8855d4002798847681f6b60bfaaf2840373 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 22 Mar 2003 03:29:06 +0000 Subject: [PATCH] Add PQfreemem() call for Win32. --- doc/src/sgml/libpq.sgml | 21 ++++++++++++++++++++- src/interfaces/libpq/fe-exec.c | 15 ++++++++++++++- src/interfaces/libpq/libpq-fe.h | 3 ++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 235a8cbc2e..3c9bc9cd2d 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 878da94cff..5b8a6d3ef0 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 8114d6e78e..ce9132deb4 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 */ -- GitLab