Archived

This topic is now archived and is closed to further replies.

dnagcat

sizeof(void *)*1

Recommended Posts

johnnie2    122
You''re taking the sizeof() a pointer, which is 4 bytes on 32-bit machines. The multiplication by one yields 4, and so your final answer is 4 bytes. The result would be the same if you took the sizeof() any type of pointer since all pointers are of the same size under a specific machine architecture.

RapscallionGL - arriving soon.

Share this post


Link to post
Share on other sites
ironfroggy    122
void* is a pointer and thus 4 (in bytes) (unless you are on a 64 bit system or something but im sure you arent) and *1 would not do anything since thats an identity operation or whatever its called.

it evaluates to 4.

Share this post


Link to post
Share on other sites
dnagcat    122
OK...so this makes sense
memset(TextureImage, 0, sizeof(void *)*1);
TextureImage is a pointer so what your doing here is clearing memory for the pointer to 0 by the size of a pointer, right?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
quote:
Original post by johnnie2
The result would be the same if you took the sizeof() any type of pointer since all pointers are of the same size under a specific machine architecture.
Not true!

In the days of 16 bit Intel machines, there were near and far pointers. I believe near pointers were 16 bits and far pointers were 32.

Also, in C++, pointers to member functions in certain circumstances can be represented in a manner different than normal machine level pointers. For example, I just wrote a small test program using VC++ 6 that prints the sizeof a pointer to a member of a class that virtually inherits a base class. The result is 12 instead of the usual 4.

Regarding the topic at hand, my guess is that the unnecessary *1 was added to "clarify" that initializing only one element was the intent.

Share this post


Link to post
Share on other sites