mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / src / kernel / vm / DynArr256.hpp
blob9c2045ab1eadc390f085a891e3207879bed7b506
1 /* Copyright (c) 2003, 2006, 2007 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef DYNARR256_HPP
17 #define DYNARR256_HPP
19 #include "Pool.hpp"
21 class DynArr256;
22 struct DA256Page;
24 class DynArr256Pool
26 friend class DynArr256;
27 public:
28 DynArr256Pool();
30 void init(Uint32 type_id, const Pool_context& pc);
32 protected:
33 Uint32 m_type_id;
34 Uint32 m_first_free;
35 Pool_context m_ctx;
36 struct DA256Page* m_memroot;
38 private:
39 Uint32 seize();
40 void release(Uint32);
43 class DynArr256
45 public:
46 struct Head
48 Head() { m_ptr_i = RNIL; m_sz = 0;}
50 Uint32 m_ptr_i;
51 Uint32 m_sz;
53 bool isEmpty() const { return m_sz == 0;}
56 DynArr256(DynArr256Pool & pool, Head& head) :
57 m_head(head), m_pool(pool){}
59 Uint32* set(Uint32 pos);
60 Uint32* get(Uint32 pos) const ;
62 struct ReleaseIterator
64 Uint32 m_sz;
65 Uint32 m_pos;
66 Uint32 m_ptr_i[5];
69 void init(ReleaseIterator&);
70 /**
71 * return 0 - done
72 * 1 - data (in retptr)
73 * 2 - nodata
75 Uint32 release(ReleaseIterator&, Uint32* retptr);
76 protected:
77 Head & m_head;
78 DynArr256Pool & m_pool;
80 bool expand(Uint32 pos);
81 void handle_invalid_ptr(Uint32 pos, Uint32 ptrI, Uint32 p0);
84 #endif