~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/dyn0dyn.h

  • Committer: Jay Pipes
  • Date: 2009-09-15 21:01:42 UTC
  • mto: (1126.2.5 merge)
  • mto: This revision was merged to the branch mainline in revision 1128.
  • Revision ID: jpipes@serialcoder-20090915210142-x8mwiqn1q0vzjspp
Moves Alter_info out into its own header and source file, cleans up some related include mess in sql_lex.h, and renames Alter_info to AlterInfo.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/dyn0dyn.h
21
 
The dynamically allocated array
22
 
 
23
 
Created 2/5/1996 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#ifndef dyn0dyn_h
27
 
#define dyn0dyn_h
28
 
 
29
 
#include "univ.i"
30
 
#include "ut0lst.h"
31
 
#include "mem0mem.h"
32
 
 
33
 
/** A block in a dynamically allocated array */
34
 
typedef struct dyn_block_struct         dyn_block_t;
35
 
/** Dynamically allocated array */
36
 
typedef dyn_block_t                     dyn_array_t;
37
 
 
38
 
 
39
 
/** This is the initial 'payload' size of a dynamic array;
40
 
this must be > MLOG_BUF_MARGIN + 30! */
41
 
#define DYN_ARRAY_DATA_SIZE     512
42
 
 
43
 
/*********************************************************************//**
44
 
Initializes a dynamic array.
45
 
@return initialized dyn array */
46
 
UNIV_INLINE
47
 
dyn_array_t*
48
 
dyn_array_create(
49
 
/*=============*/
50
 
        dyn_array_t*    arr);   /*!< in: pointer to a memory buffer of
51
 
                                size sizeof(dyn_array_t) */
52
 
/************************************************************//**
53
 
Frees a dynamic array. */
54
 
UNIV_INLINE
55
 
void
56
 
dyn_array_free(
57
 
/*===========*/
58
 
        dyn_array_t*    arr);   /*!< in: dyn array */
59
 
/*********************************************************************//**
60
 
Makes room on top of a dyn array and returns a pointer to a buffer in it.
61
 
After copying the elements, the caller must close the buffer using
62
 
dyn_array_close.
63
 
@return pointer to the buffer */
64
 
UNIV_INLINE
65
 
byte*
66
 
dyn_array_open(
67
 
/*===========*/
68
 
        dyn_array_t*    arr,    /*!< in: dynamic array */
69
 
        ulint           size);  /*!< in: size in bytes of the buffer; MUST be
70
 
                                smaller than DYN_ARRAY_DATA_SIZE! */
71
 
/*********************************************************************//**
72
 
Closes the buffer returned by dyn_array_open. */
73
 
UNIV_INLINE
74
 
void
75
 
dyn_array_close(
76
 
/*============*/
77
 
        dyn_array_t*    arr,    /*!< in: dynamic array */
78
 
        byte*           ptr);   /*!< in: buffer space from ptr up was not used */
79
 
/*********************************************************************//**
80
 
Makes room on top of a dyn array and returns a pointer to
81
 
the added element. The caller must copy the element to
82
 
the pointer returned.
83
 
@return pointer to the element */
84
 
UNIV_INLINE
85
 
void*
86
 
dyn_array_push(
87
 
/*===========*/
88
 
        dyn_array_t*    arr,    /*!< in: dynamic array */
89
 
        ulint           size);  /*!< in: size in bytes of the element */
90
 
/************************************************************//**
91
 
Returns pointer to an element in dyn array.
92
 
@return pointer to element */
93
 
UNIV_INLINE
94
 
void*
95
 
dyn_array_get_element(
96
 
/*==================*/
97
 
        dyn_array_t*    arr,    /*!< in: dyn array */
98
 
        ulint           pos);   /*!< in: position of element as bytes
99
 
                                from array start */
100
 
/************************************************************//**
101
 
Returns the size of stored data in a dyn array.
102
 
@return data size in bytes */
103
 
UNIV_INLINE
104
 
ulint
105
 
dyn_array_get_data_size(
106
 
/*====================*/
107
 
        dyn_array_t*    arr);   /*!< in: dyn array */
108
 
/************************************************************//**
109
 
Gets the first block in a dyn array. */
110
 
UNIV_INLINE
111
 
dyn_block_t*
112
 
dyn_array_get_first_block(
113
 
/*======================*/
114
 
        dyn_array_t*    arr);   /*!< in: dyn array */
115
 
/************************************************************//**
116
 
Gets the last block in a dyn array. */
117
 
UNIV_INLINE
118
 
dyn_block_t*
119
 
dyn_array_get_last_block(
120
 
/*=====================*/
121
 
        dyn_array_t*    arr);   /*!< in: dyn array */
122
 
/********************************************************************//**
123
 
Gets the next block in a dyn array.
124
 
@return pointer to next, NULL if end of list */
125
 
UNIV_INLINE
126
 
dyn_block_t*
127
 
dyn_array_get_next_block(
128
 
/*=====================*/
129
 
        dyn_array_t*    arr,    /*!< in: dyn array */
130
 
        dyn_block_t*    block); /*!< in: dyn array block */
131
 
/********************************************************************//**
132
 
Gets the number of used bytes in a dyn array block.
133
 
@return number of bytes used */
134
 
UNIV_INLINE
135
 
ulint
136
 
dyn_block_get_used(
137
 
/*===============*/
138
 
        dyn_block_t*    block); /*!< in: dyn array block */
139
 
/********************************************************************//**
140
 
Gets pointer to the start of data in a dyn array block.
141
 
@return pointer to data */
142
 
UNIV_INLINE
143
 
byte*
144
 
dyn_block_get_data(
145
 
/*===============*/
146
 
        dyn_block_t*    block); /*!< in: dyn array block */
147
 
/********************************************************//**
148
 
Pushes n bytes to a dyn array. */
149
 
UNIV_INLINE
150
 
void
151
 
dyn_push_string(
152
 
/*============*/
153
 
        dyn_array_t*    arr,    /*!< in: dyn array */
154
 
        const byte*     str,    /*!< in: string to write */
155
 
        ulint           len);   /*!< in: string length */
156
 
 
157
 
/*#################################################################*/
158
 
 
159
 
/** @brief A block in a dynamically allocated array.
160
 
NOTE! Do not access the fields of the struct directly: the definition
161
 
appears here only for the compiler to know its size! */
162
 
struct dyn_block_struct{
163
 
        mem_heap_t*     heap;   /*!< in the first block this is != NULL
164
 
                                if dynamic allocation has been needed */
165
 
        ulint           used;   /*!< number of data bytes used in this block;
166
 
                                DYN_BLOCK_FULL_FLAG is set when the block
167
 
                                becomes full */
168
 
        byte            data[DYN_ARRAY_DATA_SIZE];
169
 
                                /*!< storage for array elements */
170
 
        UT_LIST_BASE_NODE_T(dyn_block_t) base;
171
 
                                /*!< linear list of dyn blocks: this node is
172
 
                                used only in the first block */
173
 
        UT_LIST_NODE_T(dyn_block_t) list;
174
 
                                /*!< linear list node: used in all blocks */
175
 
#ifdef UNIV_DEBUG
176
 
        ulint           buf_end;/*!< only in the debug version: if dyn
177
 
                                array is opened, this is the buffer
178
 
                                end offset, else this is 0 */
179
 
        ulint           magic_n;/*!< magic number (DYN_BLOCK_MAGIC_N) */
180
 
#endif
181
 
};
182
 
 
183
 
 
184
 
#ifndef UNIV_NONINL
185
 
#include "dyn0dyn.ic"
186
 
#endif
187
 
 
188
 
#endif