1
1
<!--
2
- $Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.115 2003/03/24 18:33:52 momjian Exp $
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.116 2003/03/25 02:44:36 momjian Exp $
3
3
-->
4
4
5
5
<chapter id="libpq">
@@ -1049,8 +1049,7 @@ characters that are otherwise interpreted specially by the SQL parser.
1049
1049
<function>PQescapeString</> performs this operation.
1050
1050
</para>
1051
1051
<para>
1052
- The
1053
- parameter <parameter>from</> points to the first character of the string that
1052
+ The parameter <parameter>from</> points to the first character of the string that
1054
1053
is to be escaped, and the <parameter>length</> parameter counts the
1055
1054
number of characters in this string. (A terminating zero byte is
1056
1055
neither necessary nor counted.) <parameter>to</> shall point to a
@@ -1117,7 +1116,9 @@ unsigned char *PQescapeBytea(const unsigned char *from,
1117
1116
1118
1117
<para>
1119
1118
<function>PQescapeBytea</> returns an escaped version of the
1120
- <parameter>from</parameter> parameter binary string in memory allocated with <function>malloc()</>.
1119
+ <parameter>from</parameter> parameter binary string in memory
1120
+ allocated with <function>malloc()</>, and must be freed using
1121
+ <function>PQfreemem()</>.
1121
1122
The return string has all special characters replaced
1122
1123
so that they can be properly processed by the PostgreSQL string literal
1123
1124
parser, and the <type>bytea</type> input function. A terminating zero
@@ -1143,8 +1144,11 @@ unsigned char *PQunescapeBytea(const unsigned char *from, size_t *to_length);
1143
1144
such as might be returned by <function>PQgetvalue</function> when applied to a
1144
1145
<type>bytea</type> column. <function>PQunescapeBytea</function> converts
1145
1146
this string representation into its binary representation.
1146
- It returns a pointer to a buffer allocated with <function>malloc()</function>, or null on error, and puts the size
1147
- of the buffer in <parameter>to_length</parameter>.
1147
+ It returns a pointer to a buffer allocated with
1148
+ <function>malloc()</function>, or null on error, and puts the size of
1149
+ the buffer in <parameter>to_length</parameter>. The memory must be
1150
+ freed using <function>PQfreemem()</>.
1151
+
1148
1152
</para>
1149
1153
</listitem>
1150
1154
</varlistentry>
@@ -1161,7 +1165,9 @@ void PQfreemem(void *ptr);
1161
1165
1162
1166
<para>
1163
1167
Frees memory allocated by <application>libpq</>, particularly
1164
- <function>PQescapeBytea</function> and <function>PQunescapeBytea</function>.
1168
+ <function>PQescapeBytea</function>,
1169
+ <function>PQunescapeBytea</function>,
1170
+ and <function>PQnotifies</function>.
1165
1171
It is needed by Win32, which can not free memory across
1166
1172
DLL's, unless multithreaded DLL's (/MD in VC6) are used.
1167
1173
</para>
@@ -1926,7 +1932,7 @@ typedef struct pgNotify {
1926
1932
} PGnotify;
1927
1933
</synopsis>
1928
1934
After processing a <structname>PGnotify</structname> object returned by <function>PQnotifies</function>,
1929
- be sure to free it with <function>free ()</function> to avoid a memory leak .
1935
+ be sure to free it with <function>PQfreemem ()</function>.
1930
1936
</para>
1931
1937
1932
1938
<note>
@@ -2867,7 +2873,7 @@ main()
2867
2873
fprintf(stderr,
2868
2874
"ASYNC NOTIFY of '%s' from backend pid '%d' received\n",
2869
2875
notify->relname, notify->be_pid);
2870
- free (notify);
2876
+ PQfreemem (notify);
2871
2877
}
2872
2878
}
2873
2879
0 commit comments