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>2005-12-12 21:43:31 +0300
committerChristopher Faylor <me@cgf.cx>2005-12-12 21:43:31 +0300
commit363934dc9b9327460fefc113a3797e7e51ea2c18 (patch)
tree240bbce2428abbce4c633f33a879b4a5baba1994 /winsup/cygwin/pinfo.h
parent9941f8525d6a586843662352f28409efa18942c8 (diff)
* pinfo.cc (size_copied): New convenience macro.
(winpids::add): Alias the element that we are working on for slightly better clarity. Honor the "make_copy" flag. (winpids::release): Free and zero procinfo field if it was allocated via malloc. (winpids::~winpids): Free copied array. * pinfo.h (class pinfo): Make winpids class a friend. (winpids::make_copy): New field. (winpids::copied): New array. (winpids::reset): Reset npids after releasing pinfos or suffer a memory leak. (winpids::winpids): Try harder to allocate all fields in the class.
Diffstat (limited to 'winsup/cygwin/pinfo.h')
-rw-r--r--winsup/cygwin/pinfo.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index d0c634909..6c701d5a8 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -193,6 +193,7 @@ public:
void set_acl ();
void zap_cwd ();
friend class _pinfo;
+ friend class winpids;
};
#define ISSTATE(p, f) (!!((p)->process_state & f))
@@ -200,9 +201,11 @@ public:
class winpids
{
- DWORD *pidlist;
+ bool make_copy;
DWORD npidlist;
+ DWORD *pidlist;
pinfo *pinfolist;
+ bool *copied;
DWORD pinfo_access; // access type for pinfo open
DWORD (winpids::* enum_processes) (bool winpid);
DWORD enum_init (bool winpid);
@@ -211,15 +214,16 @@ class winpids
void add (DWORD& nelem, bool, DWORD pid);
public:
DWORD npids;
- inline void reset () { npids = 0; release (); }
+ inline void reset () { release (); npids = 0;}
void set (bool winpid);
- winpids (): enum_processes (&winpids::enum_init) {}
- winpids (int): pinfo_access (0), enum_processes (&winpids::enum_init)
- { reset (); }
- winpids (DWORD acc): pidlist (NULL), npidlist (0), pinfolist (NULL),
- enum_processes (&winpids::enum_init), npids (0)
+ winpids (): make_copy (true), enum_processes (&winpids::enum_init) {}
+ winpids (int): make_copy (false), npidlist (0), pidlist (NULL), pinfolist (NULL),
+ copied (NULL), pinfo_access (0), enum_processes (&winpids::enum_init),
+ npids (0) {}
+ winpids (DWORD acc): make_copy (false), npidlist (0), pidlist (NULL), pinfolist (NULL),
+ copied (NULL), pinfo_access (acc), enum_processes (&winpids::enum_init),
+ npids (0)
{
- pinfo_access = acc;
set (0);
}
inline DWORD& winpid (int i) const {return pidlist[i];}