size of a buffer

Started by
23 comments, last by mortex 21 years, 10 months ago
quote:Original post by gilady
Well of course the command is _msize and not sizeof.

There is no such function in Standard C or C++.
quote:
And yes c++ compiler usually (the ones I know of) write the size of the buffer they allocated in the 4 bytes before the buffer.

The Standard does not mandate that, so it is unwise to rely on it when there is a satisfactory alternative. And there is a satisfactory alternative.
Advertisement
just use a friggin std::vector

cripes
daerid@gmail.com
Just a suggestion... maybe BSTR would help you out. Bstrings have 2 (or is 4???) bytes before your pointer that tells how long the buffer is. There are functions for allocation, deletion, setting the buffer size, etc... Might be worth a look.
Vorlath you''ve got to be kidding.

Option 1: Use a well documented, standard data structure (std::vector)

Option 2: Use some obscure Win32 datatype (BSTR which is actually an OLECHAR FAR* which is god knows what, I couldn''t find any typedefs for those)

This is a tough one...

SabreMan your sig should be "SabreMan... fighting C/C++ one line of code at a time," or maybe "SabreMan... USE THE GODDAMN STL"
Hahaha. Yeah, you''re right. Unless you''re doing COM, STAY AWAY. Sorry, mental lapse on that one.

This topic is closed to new replies.

Advertisement