Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: Using speci...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 8 Topic 45810 of 47017
Post > Topic >>

Re: Using special allocator interfaces...

by "Chris Thomasson" <cristom@[EMAIL PROTECTED] > May 9, 2008 at 03:34 PM

"Chris Thomasson" <cristom@[EMAIL PROTECTED]
> wrote in message 
news:m8CdnYy2573wR77VnZ2dnUVZ_j2dnZ2d@[EMAIL PROTECTED]
> "Chris Thomasson" <cristom@[EMAIL PROTECTED]
> wrote in message 
> news:6YadndjqnMtxkL7VnZ2dnUVZ_rSrnZ2d@[EMAIL PROTECTED]
>> "Alf P. Steinbach" <alfps@[EMAIL PROTECTED]
> wrote in message
> [...]
>
>
>
>> // Can I use the above allocator interface like this:
>> template<typename T>
>> struct AllocatorBlock {
>>  unsigned char mBuffer[sizeof(T)];
>>  Allocator::Region* mRegion;
>>
>>  static void* MemRequest() {
>>    Allocator::Region* region;
>>    AllocatorBlock* const block = (AllocatorBlock*)
>>      Allocator::MemRequest(&region, sizeof(T));
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> This is in ERROR!
>
>    The size is all wrong on a per-object basis; here is correction:
>
[...]
>>  static void MemRelease(void* ptr) {
>>    AllocatorBlock* const block = (AllocatorBlock*)ptr;
>>    Allocator::MemRelease(block->mRegion, ptr, sizeof(T));
>>  }
>> };


sizeof(*block), not sizeof(T) in MemRelease:

    static void MemRelease(void* ptr) {
      AllocatorBlock* const block = (AllocatorBlock*)ptr;
      Allocator::MemRelease(block->mRegion, ptr, sizeof(*block)); // <-- !
    }


Of course!
 




 8 Posts in Topic:
Using special allocator interfaces...
"Chris Thomasson&quo  2008-05-08 06:20:47 
Re: Using special allocator interfaces...
"Alf P. Steinbach&qu  2008-05-08 15:24:33 
Re: Using special allocator interfaces...
"Chris Thomasson&quo  2008-05-08 06:44:06 
Re: Using special allocator interfaces...
"Alf P. Steinbach&qu  2008-05-08 16:00:06 
Re: Using special allocator interfaces...
"Chris Thomasson&quo  2008-05-08 07:30:35 
Re: Using special allocator interfaces...
"Chris Thomasson&quo  2008-05-08 22:03:09 
Re: Using special allocator interfaces...
"Chris Thomasson&quo  2008-05-09 15:34:04 
Re: Using special allocator interfaces...
Daniel Pitts <newsgrou  2008-05-08 08:12:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 16:08:32 CDT 2008.