[Tfug] Need help with a C++ algorithm

Stephen Hooper stephen.hooper at gmail.com
Thu Mar 15 15:42:16 MST 2007


On 3/15/07, Brian Murphy <murphy+tfug at email.arizona.edu> wrote:

>
> You should because you train yourself that way when you learn C.  But if
> we take the basic question of finding the size of the memory block and
> only the pointer is known, then you can't.  I accept your
> sizeof(string) function, but string isn't the notable pointer here --
> start is.  And sizeof(start) will return the pointer size, not the
> array size.
>
> I'll agree with you that if you can guarentee it was a dynamic
> allocation and you guarentee the allocator implementation that you can
> dig out the chunk size. :)  However that is IMO beyond only knowing a
> pointer.
>

So basically, you were just answering the question, "Is there any
sane, rational, portable, guaranteed 'way to determine the size of an
allocated block of memory if only
a pointer to it is known'?"

If that was the question, I will agree with your "No, there is not!"

>
> I figured QED was nicer than pwn3d.

Not sure,  they both made me cry :(




More information about the tfug mailing list