. . . . this is just scalped from MSDN. Well, the first part is, comments and all (http://tinyurl.com/f8jlo).
But this comment is mostly about crappy Microsoft "engineering", if you want to glorify it with that term. What kind of crap-hole design is it to make you call the same function twice to get it sized correctly?
The correct signature for this function would have been: GetIfTable(MIB_IFTABLE **, DWORD *, int) instead of: GetIfTable(MIB_IFTABLE *, DWORD *, int)
Then, the function, which _knows_ how much it needs to return, can put the data wherever it wants, and change the provided pointer value (notice the double-dereference in 'MIB_IFTABLE **'). But nooooo . . . that would make too much sense! (Being the standard C/C++ idiom for such procedures . . . )
I've got good news, and I've got bad news: The universe is merely a figment of my imagination. Now are you ready for the bad news?
Oh, and please tag Windows-specific C snippets as Windows, so those of us fortunate enough to code on POSIX-compliant systems can take no notice of them. *grin*
Don't worry, I didn't vote it down!
I've got good news, and I've got bad news: The universe is merely a figment of my imagination. Now are you ready for the bad news?
But this comment is mostly about crappy Microsoft "engineering", if you want to glorify it with that term. What kind of crap-hole design is it to make you call the same function twice to get it sized correctly?
The correct signature for this function would have been:
GetIfTable(MIB_IFTABLE **, DWORD *, int)
instead of:
GetIfTable(MIB_IFTABLE *, DWORD *, int)
Then, the function, which _knows_ how much it needs to return, can put the data wherever it wants, and change the provided pointer value (notice the double-dereference in 'MIB_IFTABLE **'). But nooooo . . . that would make too much sense! (Being the standard C/C++ idiom for such procedures . . . )
I've got good news, and I've got bad news:
The universe is merely a figment of my imagination.
Now are you ready for the bad news?
Don't worry, I didn't vote it down!
I've got good news, and I've got bad news:
The universe is merely a figment of my imagination.
Now are you ready for the bad news?
Bobby R Ward
---------------------
bobbyrward@gmail.com