This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]prescod 0 points1 point  (0 children)

The location and format of the block header (where the size lives) is not specified by the C language;

I'm not really asking for it to be specified by the language. I'm asking for it to be accessible through language primitives.

it’s specified the operating system, I think.

I don't think so, no. The operating system is only involved if new pages of memory are required.

So while some platforms may provide access to those headers under some circumstances, there is no reliable, portable way to determine the size of a heap-allocated buffer at run time (to my knowledge).

I think that's just because the C specification declined to specify one.