diff options
| author | frsyuki <frsyuki@users.sourceforge.jp> | 2010-09-26 11:37:37 +0900 |
|---|---|---|
| committer | frsyuki <frsyuki@users.sourceforge.jp> | 2010-09-26 11:37:37 +0900 |
| commit | 7974060a4010c91f978fe91e74b0e1967dc30a90 (patch) | |
| tree | 0200ed0ae62d243f245b316cc991b9fd5ab2e887 /cpp/src | |
| parent | e8abcc1765da98885d03cb0ca0784cf332bf0ee0 (diff) | |
| download | msgpack-python-7974060a4010c91f978fe91e74b0e1967dc30a90.tar.gz | |
cpp: zone: adds msgpack_zone_swap and msgpack::zone::swap
Diffstat (limited to 'cpp/src')
| -rw-r--r-- | cpp/src/msgpack/zone.h | 11 | ||||
| -rw-r--r-- | cpp/src/msgpack/zone.hpp.erb | 9 |
2 files changed, 18 insertions, 2 deletions
diff --git a/cpp/src/msgpack/zone.h b/cpp/src/msgpack/zone.h index d8c60b6..0f5817f 100644 --- a/cpp/src/msgpack/zone.h +++ b/cpp/src/msgpack/zone.h @@ -1,7 +1,7 @@ /* * MessagePack for C memory pool implementation * - * Copyright (C) 2008-2009 FURUHASHI Sadayuki + * Copyright (C) 2008-2010 FURUHASHI Sadayuki * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,6 +73,8 @@ static inline void* msgpack_zone_malloc_no_align(msgpack_zone* zone, size_t size static inline bool msgpack_zone_push_finalizer(msgpack_zone* zone, void (*func)(void* data), void* data); +static inline void msgpack_zone_swap(msgpack_zone* a, msgpack_zone* b); + bool msgpack_zone_is_empty(msgpack_zone* zone); void msgpack_zone_clear(msgpack_zone* zone); @@ -129,6 +131,13 @@ bool msgpack_zone_push_finalizer(msgpack_zone* zone, return true; } +void msgpack_zone_swap(msgpack_zone* a, msgpack_zone* b) +{ + msgpack_zone tmp = *a; + *a = *b; + *b = tmp; +} + #ifdef __cplusplus } diff --git a/cpp/src/msgpack/zone.hpp.erb b/cpp/src/msgpack/zone.hpp.erb index 1cef05e..c6f5481 100644 --- a/cpp/src/msgpack/zone.hpp.erb +++ b/cpp/src/msgpack/zone.hpp.erb @@ -1,7 +1,7 @@ // // MessagePack for C++ memory pool // -// Copyright (C) 2008-2009 FURUHASHI Sadayuki +// Copyright (C) 2008-2010 FURUHASHI Sadayuki // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -43,6 +43,8 @@ public: void clear(); + void swap(zone& o); + <%0.upto(GENERATION_LIMIT) {|i|%> template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>> T* allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>); @@ -111,6 +113,11 @@ inline void zone::clear() msgpack_zone_clear(this); } +inline void zone::swap(zone& o) +{ + msgpack_zone_swap(this, &o); +} + template <typename T> void zone::object_destructor(void* obj) { |
