Re: GetAdapapters info asking for a wrong-size buffer?
- From: "Eugene Gershnik" <gershnik@xxxxxxxxxxx>
- Date: Wed, 22 Jun 2005 14:38:18 -0700
villiros@xxxxxxxxx wrote:
> On a machine with more then one adapter, GetAdaptersInfo rightfully
> complains about a small buffer and steps into the if. However, the
> value put into outBufLen does not divide evenly by sizeof
> IP_ADAPTER_INFO.
What you are seeing is such a usual C idiom that you have to familiarize
yourself with it. A function has to return an array of complicated data
structures. You want the caller to allocate memory but asking him to
allocate each piece separately will simply be unmanageable. Instead you ask
for a one large chunk that will be enough to contain everything you need to
return and place your results in it. Unless your array items are completely
self-contained there will be no relationship between the memory size you
request and the count of items in array.
The thing to remember is to "give it what it asks for" and not try to count
sizeofs and such.
--
Eugene
http://www.gershnik.com
.
- References:
- GetAdapapters info asking for a wrong-size buffer?
- From: villiros
- GetAdapapters info asking for a wrong-size buffer?
- Prev by Date: C++ RADIUS client sample code
- Next by Date: Re: Changing listener ports
- Previous by thread: Re: GetAdapapters info asking for a wrong-size buffer?
- Next by thread: Peer to Peer SDK Graph Chat Problem
- Index(es):
Relevant Pages
|