~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
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., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
17
*****************************************************************************/
18
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
19
/******************************************************
20
The dynamically allocated array
21
22
Created 2/5/1996 Heikki Tuuri
23
*******************************************************/
24
25
#include "dyn0dyn.h"
26
#ifdef UNIV_NONINL
27
#include "dyn0dyn.ic"
28
#endif
29
30
/****************************************************************
31
Adds a new block to a dyn array. */
32
UNIV_INTERN
33
dyn_block_t*
34
dyn_array_add_block(
35
/*================*/
36
				/* out: created block */
37
	dyn_array_t*	arr)	/* in: dyn array */
38
{
39
	mem_heap_t*	heap;
40
	dyn_block_t*	block;
41
42
	ut_ad(arr);
43
	ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
44
45
	if (arr->heap == NULL) {
46
		UT_LIST_INIT(arr->base);
47
		UT_LIST_ADD_FIRST(list, arr->base, arr);
48
49
		arr->heap = mem_heap_create(sizeof(dyn_block_t));
50
	}
51
52
	block = dyn_array_get_last_block(arr);
53
	block->used = block->used | DYN_BLOCK_FULL_FLAG;
54
55
	heap = arr->heap;
56
57
	block = mem_heap_alloc(heap, sizeof(dyn_block_t));
58
59
	block->used = 0;
60
61
	UT_LIST_ADD_LAST(list, arr->base, block);
62
63
	return(block);
64
}