Re: Four questions to dll/iphlpapi/* wrt lstrcpyA.
Hi Peter, there's nothing magical in here, your understanding is correct. I'll answer each question individually though.
1) I am wondering, why sizeof(ptr->Adaptername) is used instead of MAX_ADAPTER_NAME_LENGTH+1?
That's just a style thing. I prefer sizeof(thing being copied) to MAGIC_CONSTANT in case the structure being used changes. That's unlikely in this case since the structure is defined in a public header. Since it's a style thing there's no code-behavior reason to keep it this way.
2) Is 2a supposed to be saying 15
Yes, that's just a stupid bug apparently. Why I didn't use sizeof is beyond me.
3) Why suddenly the change to use memcpy? and not some strcpy function as the code above it?
I wrote this on a different day :) --Juan __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/
On Sun, 20 Mar 2005, Juan Lang wrote:
Hi Peter, there's nothing magical in here, your understanding is correct. I'll answer each question individually though.
1) I am wondering, why sizeof(ptr->Adaptername) is used instead of MAX_ADAPTER_NAME_LENGTH+1?
That's just a style thing. I prefer sizeof(thing being copied) to MAGIC_CONSTANT in case the structure being used changes. That's unlikely in this case since the structure is defined in a public header.
It's not that unlikely. Microsoft has extended some of their structures many times in the past. That's why some of them have have these cbSize fields. -- Francois Gouget fgouget(a)free.fr http://fgouget.free.fr/ We are Pentium of Borg. You will be approximated. Division is futile.
participants (2)
-
Francois Gouget -
Juan Lang