*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.358 2008/05/16 18:30:53 mha Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.359 2008/05/29 22:02:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* needed to hold the whole message; see notes in
* pqParseInput3.
*/
- if (pqCheckInBufferSpace(conn->inCursor + msgLength, conn))
+ if (pqCheckInBufferSpace(conn->inCursor + (size_t) msgLength,
+ conn))
goto error_return;
/* We'll come back when there is more data */
return PGRES_POLLING_READING;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.194 2008/01/01 19:46:00 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.195 2008/05/29 22:02:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{
if (pqFlush(conn) < 0)
return -1;
- if (pqCheckOutBufferSpace(conn->outCount + 5 + nbytes, conn))
+ if (pqCheckOutBufferSpace(conn->outCount + 5 + (size_t) nbytes,
+ conn))
return pqIsnonblocking(conn) ? 0 : -1;
}
/* Send the data (too simple to delegate to fe-protocol files) */
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.133 2008/01/01 19:46:00 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.134 2008/05/29 22:02:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* Returns 0 on success, EOF if failed to enlarge buffer
*/
int
-pqCheckOutBufferSpace(int bytes_needed, PGconn *conn)
+pqCheckOutBufferSpace(size_t bytes_needed, PGconn *conn)
{
int newsize = conn->outBufSize;
char *newbuf;
- if (bytes_needed <= newsize)
+ if (bytes_needed <= (size_t) newsize)
return 0;
/*
do
{
newsize *= 2;
- } while (bytes_needed > newsize && newsize > 0);
+ } while (newsize > 0 && bytes_needed > (size_t) newsize);
- if (bytes_needed <= newsize)
+ if (newsize > 0 && bytes_needed <= (size_t) newsize)
{
newbuf = realloc(conn->outBuffer, newsize);
if (newbuf)
do
{
newsize += 8192;
- } while (bytes_needed > newsize && newsize > 0);
+ } while (newsize > 0 && bytes_needed > (size_t) newsize);
- if (bytes_needed <= newsize)
+ if (newsize > 0 && bytes_needed <= (size_t) newsize)
{
newbuf = realloc(conn->outBuffer, newsize);
if (newbuf)
* Returns 0 on success, EOF if failed to enlarge buffer
*/
int
-pqCheckInBufferSpace(int bytes_needed, PGconn *conn)
+pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn)
{
int newsize = conn->inBufSize;
char *newbuf;
- if (bytes_needed <= newsize)
+ if (bytes_needed <= (size_t) newsize)
return 0;
/*
do
{
newsize *= 2;
- } while (bytes_needed > newsize && newsize > 0);
+ } while (newsize > 0 && bytes_needed > (size_t) newsize);
- if (bytes_needed <= newsize)
+ if (newsize > 0 && bytes_needed <= (size_t) newsize)
{
newbuf = realloc(conn->inBuffer, newsize);
if (newbuf)
do
{
newsize += 8192;
- } while (bytes_needed > newsize && newsize > 0);
+ } while (newsize > 0 && bytes_needed > (size_t) newsize);
- if (bytes_needed <= newsize)
+ if (newsize > 0 && bytes_needed <= (size_t) newsize)
{
newbuf = realloc(conn->inBuffer, newsize);
if (newbuf)
*/
if (conn->inBufSize - conn->inEnd < 8192)
{
- if (pqCheckInBufferSpace(conn->inEnd + 8192, conn))
+ if (pqCheckInBufferSpace(conn->inEnd + (size_t) 8192, conn))
{
/*
* We don't insist that the enlarge worked, but we need some room
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.34 2008/01/17 21:21:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.35 2008/05/29 22:02:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* recovery strategy if we are unable to make the buffer big
* enough.
*/
- if (pqCheckInBufferSpace(conn->inCursor + msgLength, conn))
+ if (pqCheckInBufferSpace(conn->inCursor + (size_t) msgLength,
+ conn))
{
/*
* XXX add some better recovery code... plan is to skip over
* Before returning, enlarge the input buffer if needed to hold
* the whole message. See notes in parseInput.
*/
- if (pqCheckInBufferSpace(conn->inCursor + msgLength - 4, conn))
+ if (pqCheckInBufferSpace(conn->inCursor + (size_t) msgLength - 4,
+ conn))
{
/*
* XXX add some better recovery code... plan is to skip over
* Before looping, enlarge the input buffer if needed to hold the
* whole message. See notes in parseInput.
*/
- if (pqCheckInBufferSpace(conn->inCursor + msgLength, conn))
+ if (pqCheckInBufferSpace(conn->inCursor + (size_t) msgLength,
+ conn))
{
/*
* XXX add some better recovery code... plan is to skip over
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.130 2008/05/16 18:30:53 mha Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.131 2008/05/29 22:02:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* Get, EOF merely means the buffer is exhausted, not that there is
* necessarily any error.
*/
-extern int pqCheckOutBufferSpace(int bytes_needed, PGconn *conn);
-extern int pqCheckInBufferSpace(int bytes_needed, PGconn *conn);
+extern int pqCheckOutBufferSpace(size_t bytes_needed, PGconn *conn);
+extern int pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn);
extern int pqGetc(char *result, PGconn *conn);
extern int pqPutc(char c, PGconn *conn);
extern int pqGets(PQExpBuffer buf, PGconn *conn);