mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 21:18:23 +01:00
cpp: zone: adds msgpack_zone_swap and msgpack::zone::swap
This commit is contained in:
parent
e8abcc1765
commit
7974060a40
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* MessagePack for C memory pool implementation
|
* 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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,
|
static inline bool msgpack_zone_push_finalizer(msgpack_zone* zone,
|
||||||
void (*func)(void* data), void* data);
|
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);
|
bool msgpack_zone_is_empty(msgpack_zone* zone);
|
||||||
|
|
||||||
void msgpack_zone_clear(msgpack_zone* zone);
|
void msgpack_zone_clear(msgpack_zone* zone);
|
||||||
@ -129,6 +131,13 @@ bool msgpack_zone_push_finalizer(msgpack_zone* zone,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void msgpack_zone_swap(msgpack_zone* a, msgpack_zone* b)
|
||||||
|
{
|
||||||
|
msgpack_zone tmp = *a;
|
||||||
|
*a = *b;
|
||||||
|
*b = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// MessagePack for C++ memory pool
|
// 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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -43,6 +43,8 @@ public:
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
void swap(zone& o);
|
||||||
|
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
T* allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>);
|
T* allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>);
|
||||||
@ -111,6 +113,11 @@ inline void zone::clear()
|
|||||||
msgpack_zone_clear(this);
|
msgpack_zone_clear(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void zone::swap(zone& o)
|
||||||
|
{
|
||||||
|
msgpack_zone_swap(this, &o);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void zone::object_destructor(void* obj)
|
void zone::object_destructor(void* obj)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user