You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/05/21 01:47:43 UTC

trafficserver git commit: TS-2151 Properly eliminate the SparseClassAllocator

Repository: trafficserver
Updated Branches:
  refs/heads/master 98787bc3e -> 6565d4174


TS-2151 Properly eliminate the SparseClassAllocator


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/6565d417
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/6565d417
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/6565d417

Branch: refs/heads/master
Commit: 6565d417411b507ac7f6733a591ff121858f2c18
Parents: 98787bc
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed May 20 17:47:37 2015 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed May 20 17:47:37 2015 -0600

----------------------------------------------------------------------
 lib/ts/Allocator.h  | 46 ----------------------------------------------
 proxy/http/HttpSM.h |  2 +-
 2 files changed, 1 insertion(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6565d417/lib/ts/Allocator.h
----------------------------------------------------------------------
diff --git a/lib/ts/Allocator.h b/lib/ts/Allocator.h
index b243901..6478cce 100644
--- a/lib/ts/Allocator.h
+++ b/lib/ts/Allocator.h
@@ -201,51 +201,5 @@ public:
   } proto;
 };
 
-/**
-  Allocator for space class, a class with a lot of uninitialized
-  space/members. It uses an instantiate function do initialization
-  of objects. This is particularly useful if most of the space in
-  the objects does not need to be initialized. The initialization function passed
-  can be used to initialize a few fields selectively. Using
-  ClassAllocator for space objects would unnecessarily initialized
-  all of the members.
-
-*/
-template <class C> class SparseClassAllocator : public ClassAllocator<C>
-{
-public:
-  /** Allocates objects of the templated type. */
-  C *
-  alloc()
-  {
-    void *ptr = ink_freelist_new(this->fl);
-
-    if (!_instantiate) {
-      memcpy(ptr, (void *)&this->proto.typeObject, sizeof(C));
-    } else
-      (*_instantiate)((C *)&this->proto.typeObject, (C *)ptr);
-    return (C *)ptr;
-  }
-
-
-  /**
-    Create a new class specific SparseClassAllocator.
-
-    @param name some identifying name, used for mem tracking purposes.
-    @param chunk_size number of units to be allocated if free pool is empty.
-    @param alignment of objects must be a power of 2.
-    @param instantiate_func
-
-  */
-  SparseClassAllocator(const char *name, unsigned int chunk_size = 128, unsigned int alignment = 16,
-                       void (*instantiate_func)(C *proto, C *instance) = NULL)
-    : ClassAllocator<C>(name, chunk_size, alignment)
-  {
-    _instantiate = instantiate_func; // NULL by default
-  }
-
-private:
-  void (*_instantiate)(C *proto, C *instance);
-};
 
 #endif // _Allocator_h_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6565d417/proxy/http/HttpSM.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h
index a15142f..47f98eb 100644
--- a/proxy/http/HttpSM.h
+++ b/proxy/http/HttpSM.h
@@ -559,7 +559,7 @@ HttpSM::get_ua_entry()
 inline HttpSM *
 HttpSM::allocate()
 {
-  extern SparseClassAllocator<HttpSM> httpSMAllocator;
+  extern ClassAllocator<HttpSM> httpSMAllocator;
   return httpSMAllocator.alloc();
 }