Rafal wrote:[color=blue]
>
davidrubin@warpmail.net wrote:
>[color=green]
> >
> > How about
> >
> > *(unsigned int *)m = sz;
> >
> > instead of
> >
> > *(unsigned int *)m = sz + 4;
> >
> > in your overloaded 'new'? /david[/color]
>
> When I'm allocationg 4 bytes extra to store the size of allocated memory:[color=green][color=darkred]
> >> void* m = malloc(sz+4);[/color][/color]
> I count them as allocated:[color=green][color=darkred]
> >> *(unsigned int*)m = sz+4;[/color][/color]
> Couse I want to know how much memory is deallocated when I use delete:[color=green][color=darkred]
> >> void operator delete[](void* m) {
> >> if (!m) return;
> >>
> >> m = (char*)m-4;
> >> memory -= *(unsigned int*)m;[/color][/color]
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[/color]
I thought the intent was to monitor how much memory your process uses
under normal curcumstances, without this "test" allocator. In that
case, you don't want to count the test allocator overhead. Otherwise,
you actually *are* using an extra four bytes, and you need to count
them, as you do.
/david