* dtable.h (dtable::first_fd_for_open): Change declaration to size_t.

(dtable::extend): Change parameter to size_t.
(dtable::find_unused_handle): Ditto.
* dtable.cc: Remove now-unused header.
(dtable::extend): Remove pointless test.  Change parameter to size_t.
(dtable::find_unused_handle): Rework to avoid MAX calculation in extend() call.
Change parameter to size_t.
This commit is contained in:
Christopher Faylor
2013-12-01 02:52:54 +00:00
parent 483c843a6a
commit 499494d2cc
3 changed files with 18 additions and 10 deletions

View File

@ -16,7 +16,6 @@ details. */
#include <stdio.h>
#include <unistd.h>
#include <wchar.h>
#include <sys/param.h>
#define USE_SYS_TYPES_FD_SET
#include <winsock.h>
@ -73,14 +72,11 @@ set_std_handle (int fd)
}
int
dtable::extend (int howmuch)
dtable::extend (size_t howmuch)
{
int new_size = size + howmuch;
fhandler_base **newfds;
if (howmuch <= 0)
return 0;
if (new_size > OPEN_MAX_MAX)
{
set_errno (EMFILE);
@ -225,8 +221,10 @@ dtable::delete_archetype (fhandler_base *fh)
}
int
dtable::find_unused_handle (int start)
dtable::find_unused_handle (size_t start)
{
size_t extendby = (start > size) ? start - size : NOFILE_INCR;
/* This do loop should only ever execute twice. */
do
{
for (size_t i = start; i < size; i++)
@ -234,7 +232,7 @@ dtable::find_unused_handle (int start)
if (fds[i] == NULL)
return i;
}
while (extend (MAX (NOFILE_INCR, start - size)));
while (extend (extendby));
return -1;
}