Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3e4978b

Browse files
committed
Fix free-slot search in PgSetResultId so it actually works.
1 parente313eb8 commit3e4978b

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

‎src/interfaces/libpgtcl/pgtclId.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.36 2002/09/23 01:43:23 momjian Exp $
16+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.37 2002/10/17 14:53:32 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -340,30 +340,34 @@ PgSetResultId(Tcl_Interp *interp, char *connid_c, PGresult *res)
340340
returnTCL_ERROR;
341341
connid= (Pg_ConnectionId*)Tcl_GetChannelInstanceData(conn_chan);
342342

343-
for (resid=connid->res_last+1;resid!=connid->res_last;resid++)
343+
/* search, starting at slot after the last one used */
344+
resid=connid->res_last;
345+
for (;;)
344346
{
345-
if (resid==connid->res_max)
346-
{
347+
/* advance, with wraparound */
348+
if (++resid >=connid->res_max)
347349
resid=0;
348-
break;
349-
}
350+
/* this slot empty? */
350351
if (!connid->results[resid])
351352
{
352353
connid->res_last=resid;
353-
break;
354+
break;/* success exit */
354355
}
356+
/* checked all slots? */
357+
if (resid==connid->res_last)
358+
break;/* failure exit */
355359
}
356360

357361
if (connid->results[resid])
358362
{
359-
if (connid->res_max==connid->res_hardmax)
363+
/* no free slot found, so try to enlarge array */
364+
if (connid->res_max >=connid->res_hardmax)
360365
{
361366
Tcl_SetResult(interp,"hard limit on result handles reached",
362367
TCL_STATIC);
363368
returnTCL_ERROR;
364369
}
365-
connid->res_last=connid->res_max;
366-
resid=connid->res_max;
370+
connid->res_last=resid=connid->res_max;
367371
connid->res_max *=2;
368372
if (connid->res_max>connid->res_hardmax)
369373
connid->res_max=connid->res_hardmax;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp