~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/dict/dict0mem.c

  • Committer: Monty Taylor
  • Date: 2010-12-03 19:56:07 UTC
  • mto: (1975.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1976.
  • Revision ID: mordred@inaugust.com-20101203195607-yw50aynlw04dt5k6
All protocol stuff except for the buffer_length. WTF?

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
64
64
        mem_heap_t*     heap;
65
65
 
66
66
        ut_ad(name);
67
 
        ut_a(!(flags & (SIZE_MAX << DICT_TF2_BITS)));
 
67
        ut_a(!(flags & (~0 << DICT_TF2_BITS)));
68
68
 
69
69
        heap = mem_heap_create(DICT_HEAP_SIZE);
70
70
 
71
 
        table = static_cast<dict_table_struct *>(mem_heap_zalloc(heap, sizeof(dict_table_t)));
 
71
        table = mem_heap_zalloc(heap, sizeof(dict_table_t));
72
72
 
73
73
        table->heap = heap;
74
74
 
75
75
        table->flags = (unsigned int) flags;
76
 
        table->name = static_cast<char *>(ut_malloc(strlen(name) + 1));
77
 
        memcpy(table->name, name, strlen(name) + 1);
 
76
        table->name = mem_heap_strdup(heap, name);
78
77
        table->space = (unsigned int) space;
79
78
        table->n_cols = (unsigned int) (n_cols + DATA_N_SYS_COLS);
80
79
 
81
 
        table->cols = static_cast<dict_col_t *>(mem_heap_alloc(heap, (n_cols + DATA_N_SYS_COLS)
82
 
                                     * sizeof(dict_col_t)));
 
80
        table->cols = mem_heap_alloc(heap, (n_cols + DATA_N_SYS_COLS)
 
81
                                     * sizeof(dict_col_t));
83
82
 
84
83
#ifndef UNIV_HOTBACKUP
85
 
        table->autoinc_lock = static_cast<lock_t *>(mem_heap_alloc(heap, lock_get_size()));
 
84
        table->autoinc_lock = mem_heap_alloc(heap, lock_get_size());
86
85
 
87
86
        mutex_create(autoinc_mutex_key,
88
87
                     &table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
113
112
#ifndef UNIV_HOTBACKUP
114
113
        mutex_free(&(table->autoinc_mutex));
115
114
#endif /* UNIV_HOTBACKUP */
116
 
        ut_free(table->name);
117
115
        mem_heap_free(table->heap);
118
116
}
119
117
 
154
152
        new_len = strlen(name) + 1;
155
153
        total_len = old_len + new_len;
156
154
 
157
 
        res = static_cast<char *>(mem_heap_alloc(heap, total_len));
 
155
        res = mem_heap_alloc(heap, total_len);
158
156
 
159
157
        if (old_len > 0) {
160
158
                memcpy(res, col_names, old_len);
193
191
                }
194
192
                if (UNIV_LIKELY(i) && UNIV_UNLIKELY(!table->col_names)) {
195
193
                        /* All preceding column names are empty. */
196
 
                        char* s = static_cast<char *>(mem_heap_zalloc(heap, table->n_def));
 
194
                        char* s = mem_heap_zalloc(heap, table->n_def);
197
195
                        table->col_names = s;
198
196
                }
199
197
 
206
204
        dict_mem_fill_column_struct(col, i, mtype, prtype, len);
207
205
}
208
206
 
209
 
 
210
 
/**********************************************************************//**
211
 
This function populates a dict_col_t memory structure with
212
 
supplied information. */
213
 
UNIV_INTERN
214
 
void
215
 
dict_mem_fill_column_struct(
216
 
/*========================*/
217
 
        dict_col_t*     column,         /*!< out: column struct to be
218
 
                                        filled */
219
 
        ulint           col_pos,        /*!< in: column position */
220
 
        ulint           mtype,          /*!< in: main data type */
221
 
        ulint           prtype,         /*!< in: precise type */
222
 
        ulint           col_len)        /*!< in: column length */
223
 
{
224
 
#ifndef UNIV_HOTBACKUP
225
 
        ulint   mbminlen;
226
 
        ulint   mbmaxlen;
227
 
#endif /* !UNIV_HOTBACKUP */
228
 
 
229
 
        column->ind = (unsigned int) col_pos;
230
 
        column->ord_part = 0;
231
 
        column->mtype = (unsigned int) mtype;
232
 
        column->prtype = (unsigned int) prtype;
233
 
        column->len = (unsigned int) col_len;
234
 
#ifndef UNIV_HOTBACKUP
235
 
        dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen);
236
 
        dict_col_set_mbminmaxlen(column, mbminlen, mbmaxlen);
237
 
#endif /* !UNIV_HOTBACKUP */
238
 
}
239
 
 
240
207
/**********************************************************************//**
241
208
Creates an index memory object.
242
209
@return own: index object */
259
226
        ut_ad(table_name && index_name);
260
227
 
261
228
        heap = mem_heap_create(DICT_HEAP_SIZE);
262
 
        index = static_cast<dict_index_t *>(mem_heap_zalloc(heap, sizeof(dict_index_t)));
 
229
        index = mem_heap_zalloc(heap, sizeof(dict_index_t));
263
230
 
264
231
        dict_mem_fill_index_struct(index, heap, table_name, index_name,
265
232
                                   space, type, n_fields);
280
247
 
281
248
        heap = mem_heap_create(100);
282
249
 
283
 
        foreign = static_cast<dict_foreign_t *>(mem_heap_zalloc(heap, sizeof(dict_foreign_t)));
 
250
        foreign = mem_heap_zalloc(heap, sizeof(dict_foreign_t));
284
251
 
285
252
        foreign->heap = heap;
286
253