From 3feff4ae44fd74c32158ed5f505e063b154c4d76 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期四, 16 七月 2020 11:43:34 +0800 Subject: [PATCH] udpate --- queue/include/shm_allocator.h | 36 ++++++++++++++++++++++++++++++------ 1 files changed, 30 insertions(+), 6 deletions(-) diff --git a/queue/include/shm_allocator.h b/queue/include/shm_allocator.h index f9e838b..700f786 100644 --- a/queue/include/shm_allocator.h +++ b/queue/include/shm_allocator.h @@ -9,7 +9,7 @@ -template<class T> class SHMAllocator +template<class T> class SHM_STL_Allocator { public: typedef T value_type; @@ -21,10 +21,10 @@ typedef ptrdiff_t difference_type; - SHMAllocator() {}; - ~SHMAllocator() {}; - template<class U> SHMAllocator(const SHMAllocator<U>& t) { }; - template<class U> struct rebind { typedef SHMAllocator<U> other; }; + SHM_STL_Allocator() {}; + ~SHM_STL_Allocator() {}; + template<class U> SHM_STL_Allocator(const SHM_STL_Allocator<U>& t) { }; + template<class U> struct rebind { typedef SHM_STL_Allocator<U> other; }; pointer allocate(size_type n, const void* hint=0) { // fprintf(stderr, "allocate n=%u, hint= %p\n",n, hint); @@ -63,12 +63,36 @@ }; +class SHM_Allocator { + public: + static void *malloc (size_t size) { + return mm_malloc(size); + } + + static void free (void *ptr) { + return mm_free(ptr); + } +}; + + +class DM_Allocator { + public: + static void *malloc (size_t size) { + return malloc(size); + } + + static void free (void *ptr) { + return free(ptr); + } +}; + + // template<class charT, class traits = char _traits<charT>, // class Allocator = allocator<charT> > -typedef std::basic_string<char, std::char_traits<char>, SHMAllocator<char> > shmstring; +typedef std::basic_string<char, std::char_traits<char>, SHM_STL_Allocator<char> > shmstring; #endif \ No newline at end of file -- Gitblit v1.8.0