Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2010-08-09 20:53:35 +0400
committerChristopher Faylor <me@cgf.cx>2010-08-09 20:53:35 +0400
commit514fdad34d5d3fcaec6334d78a01e5f8a4d225ad (patch)
tree02caedad23d5c59d796a8ee3a47d7d93b2796657 /winsup/cygwin/cygheap.h
parent6d27f8298558737d86fac8646d4ad37ee83a7347 (diff)
* cygheap.h (cygheap_fdmanip): Delete fh and use fd index into cygheap->fdtab
throughout. (cygheap_fdnew): Replace fh by using fd index into cygheap->fdtab throughout. (cygheap_fdget): Ditto. (cygheap_fdenum): Ditto.
Diffstat (limited to 'winsup/cygwin/cygheap.h')
-rw-r--r--winsup/cygwin/cygheap.h27
1 files changed, 11 insertions, 16 deletions
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 764e72240..34c85997d 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -314,10 +314,9 @@ class cygheap_fdmanip
{
protected:
int fd;
- fhandler_base **fh;
bool locked;
public:
- cygheap_fdmanip (): fh (NULL) {}
+ cygheap_fdmanip (): fd (-1), locked (false) {}
virtual ~cygheap_fdmanip ()
{
if (locked)
@@ -328,14 +327,14 @@ class cygheap_fdmanip
cygheap->fdtab.release (fd);
}
operator int &() {return fd;}
- operator fhandler_base* &() {return *fh;}
- operator fhandler_socket* () const {return reinterpret_cast<fhandler_socket *> (*fh);}
- operator fhandler_pipe* () const {return reinterpret_cast<fhandler_pipe *> (*fh);}
- void operator = (fhandler_base *fh) {*this->fh = fh;}
- fhandler_base *operator -> () const {return *fh;}
+ operator fhandler_base* &() {return cygheap->fdtab[fd];}
+ operator fhandler_socket* () const {return reinterpret_cast<fhandler_socket *> (cygheap->fdtab[fd]);}
+ operator fhandler_pipe* () const {return reinterpret_cast<fhandler_pipe *> (cygheap->fdtab[fd]);}
+ void operator = (fhandler_base *fh) {cygheap->fdtab[fd] = fh;}
+ fhandler_base *operator -> () const {return cygheap->fdtab[fd];}
bool isopen () const
{
- if (*fh)
+ if (cygheap->fdtab[fd])
return true;
set_errno (EBADF);
return false;
@@ -354,10 +353,7 @@ class cygheap_fdnew : public cygheap_fdmanip
else
fd = cygheap->fdtab.find_unused_handle (seed_fd + 1);
if (fd >= 0)
- {
- locked = lockit;
- fh = cygheap->fdtab + fd;
- }
+ locked = lockit;
else
{
set_errno (EMFILE);
@@ -366,7 +362,7 @@ class cygheap_fdnew : public cygheap_fdmanip
locked = false;
}
}
- void operator = (fhandler_base *fh) {*this->fh = fh;}
+ void operator = (fhandler_base *fh) {cygheap->fdtab[fd] = fh;}
};
class cygheap_fdget : public cygheap_fdmanip
@@ -376,8 +372,7 @@ class cygheap_fdget : public cygheap_fdmanip
{
if (lockit)
cygheap->fdtab.lock ();
- if (fd >= 0 && fd < (int) cygheap->fdtab.size
- && *(fh = cygheap->fdtab + fd) != NULL)
+ if (fd >= 0 && fd < (int) cygheap->fdtab.size && cygheap->fdtab[fd] != NULL)
{
this->fd = fd;
locked = lockit;
@@ -407,7 +402,7 @@ class cygheap_fdenum : public cygheap_fdmanip
int next ()
{
while (++fd < (int) cygheap->fdtab.size)
- if (*(fh = cygheap->fdtab + fd) != NULL)
+ if (cygheap->fdtab[fd] != NULL)
return fd;
return -1;
}