From a76a94009d78a6a41654335dcb9202fb31659de0 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期四, 25 三月 2021 13:23:16 +0800
Subject: [PATCH] bulid msg, refactor.

---
 src/shm.h |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/shm.h b/src/shm.h
index 91a339d..808ed5d 100644
--- a/src/shm.h
+++ b/src/shm.h
@@ -54,6 +54,11 @@
     {}
     std::string name() const { return name_; }
     bool Remove() { return Remove(name()); }
+
+    void *Alloc(const size_t size) { return allocate(size, std::nothrow); }
+    void Dealloc(void *p) { if(p) { deallocate(p); } }
+    template<class T> void Dealloc(offset_ptr<T> ptr) { return Dealloc(ptr.get()); }
+
     template <class T, class ...Params> T * New(Params const&...params) { return construct<T>(anonymous_instance, std::nothrow)(params...); }
     template <class T> void Delete(T *p) { if (p) { destroy_ptr<T>(p); }; }
     template <class T> void Delete(offset_ptr<T> p) { Delete(p.get()); }
@@ -75,7 +80,7 @@
 
     bool IsOk() const { return pdata_; }
 protected:
-    ShmType &shm() { return shm_; }
+    ShmType &shm() const { return shm_; }
 public:
     template <class...Params>
     ShmObject(ShmType &segment, const std::string &name, Params&&...t):

--
Gitblit v1.8.0