diff options
author | Kyungwook Tak <k.tak@samsung.com> | 2016-04-12 19:19:09 +0900 |
---|---|---|
committer | Kyungwook Tak <k.tak@samsung.com> | 2016-04-18 15:36:25 +0900 |
commit | ebd0c830669ce3c374f262a4a1b0e8063f2e443f (patch) | |
tree | 5beec35f8bb1a63845052f3bc17e21945f7e19be /src/include/ckm/ckm-raw-buffer.h | |
parent | 5e4916bf2e05adb0c078aa9eacf24d7686dbee7c (diff) | |
download | key-manager-ebd0c830669ce3c374f262a4a1b0e8063f2e443f.tar.gz key-manager-ebd0c830669ce3c374f262a4a1b0e8063f2e443f.tar.bz2 key-manager-ebd0c830669ce3c374f262a4a1b0e8063f2e443f.zip |
Coding style applied according to style checkersubmit/tizen/20160418.104308accepted/tizen/wearable/20160418.235737accepted/tizen/tv/20160418.235750accepted/tizen/mobile/20160418.235742accepted/tizen/ivi/20160418.235747accepted/tizen/common/20160418.142113
Checker/Guide in http://10.113.136.204/confluence/pages/viewpage.action?pageId=44567756
Change-Id: Ie1c934dcc898b72a68b7a56d43eea4a3298b509c
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
Diffstat (limited to 'src/include/ckm/ckm-raw-buffer.h')
-rw-r--r-- | src/include/ckm/ckm-raw-buffer.h | 106 |
1 files changed, 54 insertions, 52 deletions
diff --git a/src/include/ckm/ckm-raw-buffer.h b/src/include/ckm/ckm-raw-buffer.h index 6ac4ab61..8ae908f0 100644 --- a/src/include/ckm/ckm-raw-buffer.h +++ b/src/include/ckm/ckm-raw-buffer.h @@ -30,65 +30,67 @@ namespace CKM { template <typename T> struct std_erase_on_dealloc { - // MJK: if re-factoring, remember not to inherit from the std::allocator ! - // MJK: to be replaced with much shorter version once std::allocator_traits - // becomes supported in STL containers (i.e. list, vector and string) - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef T value_type; - - std_erase_on_dealloc() = default; - - template <typename U> - std_erase_on_dealloc(const std_erase_on_dealloc<U>&) {} - - T* allocate(std::size_t n) - { - return static_cast<T*>(::operator new(n*sizeof(T))); - } - - void deallocate(T* ptr, std::size_t n) - { - // clear the memory before deleting - memset(ptr, 0 , n * sizeof(T)); - ::operator delete(ptr); - } - - template<typename _Tp1> - struct rebind { - typedef std_erase_on_dealloc<_Tp1> other; - }; - - void construct(pointer p, const T& val) - { - new (p) T(val); - } - - void destroy(pointer p) - { - p->~T(); - } - - size_type max_size() const - { - return size_type(-1); - } + // MJK: if re-factoring, remember not to inherit from the std::allocator ! + // MJK: to be replaced with much shorter version once std::allocator_traits + // becomes supported in STL containers (i.e. list, vector and string) + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T *pointer; + typedef const T *const_pointer; + typedef T &reference; + typedef const T &const_reference; + typedef T value_type; + + std_erase_on_dealloc() = default; + + template <typename U> + std_erase_on_dealloc(const std_erase_on_dealloc<U> &) {} + + T *allocate(std::size_t n) + { + return static_cast<T *>(::operator new(n * sizeof(T))); + } + + void deallocate(T *ptr, std::size_t n) + { + // clear the memory before deleting + memset(ptr, 0 , n * sizeof(T)); + ::operator delete(ptr); + } + + template<typename _Tp1> + struct rebind { + typedef std_erase_on_dealloc<_Tp1> other; + }; + + void construct(pointer p, const T &val) + { + new(p) T(val); + } + + void destroy(pointer p) + { + p->~T(); + } + + size_type max_size() const + { + return size_type(-1); + } }; template <typename T, typename U> -inline bool operator == (const std_erase_on_dealloc<T>&, const std_erase_on_dealloc<U>&) +inline bool operator==(const std_erase_on_dealloc<T> &, + const std_erase_on_dealloc<U> &) { - return true; + return true; } template <typename T, typename U> -inline bool operator != (const std_erase_on_dealloc<T>& a, const std_erase_on_dealloc<U>& b) +inline bool operator!=(const std_erase_on_dealloc<T> &a, + const std_erase_on_dealloc<U> &b) { - return !(a == b); + return !(a == b); } @@ -104,7 +106,7 @@ inline bool operator != (const std_erase_on_dealloc<T>& a, const std_erase_on_de */ template <typename T> struct SafeBuffer { - typedef std::vector<T, std_erase_on_dealloc<T>> Type; + typedef std::vector<T, std_erase_on_dealloc<T>> Type; }; // used to pass password and raw key data |