00001 /***************************************************************************** 00002 00003 Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it under 00006 the terms of the GNU General Public License as published by the Free Software 00007 Foundation; version 2 of the License. 00008 00009 This program is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License along with 00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin 00015 St, Fifth Floor, Boston, MA 02110-1301 USA 00016 00017 *****************************************************************************/ 00018 00019 /**************************************************/ 00026 #pragma once 00027 #ifndef dyn0dyn_h 00028 #define dyn0dyn_h 00029 00030 #include "univ.i" 00031 #include "ut0lst.h" 00032 #include "mem0mem.h" 00033 00035 typedef struct dyn_block_struct dyn_block_t; 00037 typedef dyn_block_t dyn_array_t; 00038 00039 00042 #define DYN_ARRAY_DATA_SIZE 512 00043 00044 /*********************************************************************/ 00047 UNIV_INLINE 00048 dyn_array_t* 00049 dyn_array_create( 00050 /*=============*/ 00051 dyn_array_t* arr); 00053 /************************************************************/ 00055 UNIV_INLINE 00056 void 00057 dyn_array_free( 00058 /*===========*/ 00059 dyn_array_t* arr); 00060 /*********************************************************************/ 00065 UNIV_INLINE 00066 byte* 00067 dyn_array_open( 00068 /*===========*/ 00069 dyn_array_t* arr, 00070 ulint size); 00072 /*********************************************************************/ 00074 UNIV_INLINE 00075 void 00076 dyn_array_close( 00077 /*============*/ 00078 dyn_array_t* arr, 00079 byte* ptr); 00080 /*********************************************************************/ 00085 UNIV_INLINE 00086 void* 00087 dyn_array_push( 00088 /*===========*/ 00089 dyn_array_t* arr, 00090 ulint size); 00091 /************************************************************/ 00094 UNIV_INLINE 00095 void* 00096 dyn_array_get_element( 00097 /*==================*/ 00098 dyn_array_t* arr, 00099 ulint pos); 00101 /************************************************************/ 00104 UNIV_INLINE 00105 ulint 00106 dyn_array_get_data_size( 00107 /*====================*/ 00108 dyn_array_t* arr); 00109 /************************************************************/ 00111 UNIV_INLINE 00112 dyn_block_t* 00113 dyn_array_get_first_block( 00114 /*======================*/ 00115 dyn_array_t* arr); 00116 /************************************************************/ 00118 UNIV_INLINE 00119 dyn_block_t* 00120 dyn_array_get_last_block( 00121 /*=====================*/ 00122 dyn_array_t* arr); 00123 /********************************************************************/ 00126 UNIV_INLINE 00127 dyn_block_t* 00128 dyn_array_get_next_block( 00129 /*=====================*/ 00130 dyn_array_t* arr, 00131 dyn_block_t* block); 00132 /********************************************************************/ 00135 UNIV_INLINE 00136 ulint 00137 dyn_block_get_used( 00138 /*===============*/ 00139 dyn_block_t* block); 00140 /********************************************************************/ 00143 UNIV_INLINE 00144 byte* 00145 dyn_block_get_data( 00146 /*===============*/ 00147 dyn_block_t* block); 00148 /********************************************************/ 00150 UNIV_INLINE 00151 void 00152 dyn_push_string( 00153 /*============*/ 00154 dyn_array_t* arr, 00155 const byte* str, 00156 ulint len); 00158 /*#################################################################*/ 00159 00163 struct dyn_block_struct{ 00164 mem_heap_t* heap; 00166 ulint used; 00169 byte data[DYN_ARRAY_DATA_SIZE]; 00171 UT_LIST_BASE_NODE_T(dyn_block_t) base; 00174 UT_LIST_NODE_T(dyn_block_t) list; 00176 #ifdef UNIV_DEBUG 00177 ulint buf_end; 00180 ulint magic_n; 00181 #endif 00182 }; 00183 00184 00185 #ifndef UNIV_NONINL 00186 #include "dyn0dyn.ic" 00187 #endif 00188 00189 #endif