~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to storage/innobase/dyn/dyn0dyn.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 1996, 2013, Oracle and/or its affiliates. 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.,
 
15
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/**************************************************//**
 
20
@file dyn/dyn0dyn.cc
 
21
The dynamically allocated array
 
22
 
 
23
Created 2/5/1996 Heikki Tuuri
 
24
*******************************************************/
 
25
 
 
26
#include "dyn0dyn.h"
 
27
#ifdef UNIV_NONINL
 
28
#include "dyn0dyn.ic"
 
29
#endif
 
30
 
 
31
/************************************************************//**
 
32
Adds a new block to a dyn array.
 
33
@return created block */
 
34
UNIV_INTERN
 
35
dyn_block_t*
 
36
dyn_array_add_block(
 
37
/*================*/
 
38
        dyn_array_t*    arr)    /*!< in/out: dyn array */
 
39
{
 
40
        mem_heap_t*     heap;
 
41
        dyn_block_t*    block;
 
42
 
 
43
        ut_ad(arr);
 
44
        ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
 
45
 
 
46
        if (arr->heap == NULL) {
 
47
                UT_LIST_INIT(arr->base);
 
48
                UT_LIST_ADD_FIRST(list, arr->base, arr);
 
49
 
 
50
                arr->heap = mem_heap_create(sizeof(dyn_block_t));
 
51
        }
 
52
 
 
53
        block = dyn_array_get_last_block(arr);
 
54
        block->used = block->used | DYN_BLOCK_FULL_FLAG;
 
55
 
 
56
        heap = arr->heap;
 
57
 
 
58
        block = static_cast<dyn_block_t*>(
 
59
                mem_heap_alloc(heap, sizeof(dyn_block_t)));
 
60
 
 
61
        block->used = 0;
 
62
 
 
63
        UT_LIST_ADD_LAST(list, arr->base, block);
 
64
 
 
65
        return(block);
 
66
}