how to pass by reference??

David Bolen db3l at fitlinxx.com
Mon Feb 4 15:48:27 EST 2002


"Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> writes:

> According to the help file, you need a PyOVERLAPPEDReadBuffer object here,
> whatever that is... Mark Hammond, are you out there?

You get this by using win32file.AllocateReadBuffer().  I believe
that's just a renamed buffer object, so it's possible that a normal
buffer object would work too, but there's the nice API function to use
after all.

> I've lost track; why are you passing in a buffer?  Don't you get the bytes
> read as the second return value from ReadFile?  Have you read the help
> file yet?

The second return value is actually the resultant buffer itself.  From
what I can see the only reason to pass in a buffer to ReadFile itself
is if you're using overlapped I/O and might not keep the result in
scope before the I/O completes.  In that case, you might want to
allocate the buffer in some other scope (with AllocateReadBuffer).  If
you pass the buffer in to ReadFile, than a reference to that same
buffer is what is returned by the function.

But I'm not really sure you ever need to allocate your own buffer -
after all, even if you're going to leave the scope where the function
is called, as long as you pass back the resultant buffer pointer the
object should always be alive while the I/O is ongoing.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list