trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Peach <jpe...@apache.org>
Subject Re: trafficserver git commit: TS-4007: ClassAllocator: don't attempt to destruct the prototype object when ClassAllocator goes out of scope
Date Tue, 10 Nov 2015 18:17:37 GMT

> On Nov 9, 2015, at 10:38 PM, briang@apache.org wrote:
> 
> Repository: trafficserver
> Updated Branches:
>  refs/heads/master c7610467e -> e4cb30531
> 
> 
> TS-4007: ClassAllocator: don't attempt to destruct the prototype object when ClassAllocator
goes out of scope
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e4cb3053
> Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e4cb3053
> Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e4cb3053
> 
> Branch: refs/heads/master
> Commit: e4cb305315e4969748c9dc8414fd96c8d36b4091
> Parents: c761046
> Author: Can Selcik <cselcik@linkedin.com>
> Authored: Mon Nov 9 22:29:37 2015 -0800
> Committer: Brian Geffon <briang@apache.org>
> Committed: Mon Nov 9 22:38:24 2015 -0800
> 
> ----------------------------------------------------------------------
> lib/ts/Allocator.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e4cb3053/lib/ts/Allocator.h
> ----------------------------------------------------------------------
> diff --git a/lib/ts/Allocator.h b/lib/ts/Allocator.h
> index 3b489a7..a21ff90 100644
> --- a/lib/ts/Allocator.h
> +++ b/lib/ts/Allocator.h
> @@ -40,6 +40,7 @@
> #ifndef _Allocator_h_
> #define _Allocator_h_
> 
> +#include <new>
> #include <stdlib.h>
> #include "ts/ink_queue.h"
> #include "ts/ink_defs.h"
> @@ -193,11 +194,12 @@ public:
>   */
>   ClassAllocator(const char *name, unsigned int chunk_size = 128, unsigned int alignment
= 16)
>   {
> +    ::new ((void*)&proto.typeObject) C();
>     ink_freelist_init(&this->fl, name, RND16(sizeof(C)), chunk_size, RND16(alignment));
>   }
> 
>   struct {
> -    C typeObject;
> +    uint8_t typeObject[sizeof(C)];

I think this should be union'ed to guarantee correct alignment?

>     int64_t space_holder;
>   } proto;
> };
> 


Mime
View raw message