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 #include "dyn0dyn.h" 00027 #ifdef UNIV_NONINL 00028 #include "dyn0dyn.ic" 00029 #endif 00030 00031 /************************************************************/ 00034 UNIV_INTERN 00035 dyn_block_t* 00036 dyn_array_add_block( 00037 /*================*/ 00038 dyn_array_t* arr) 00039 { 00040 mem_heap_t* heap; 00041 dyn_block_t* block; 00042 00043 ut_ad(arr); 00044 ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N); 00045 00046 if (arr->heap == NULL) { 00047 UT_LIST_INIT(arr->base); 00048 UT_LIST_ADD_FIRST(list, arr->base, arr); 00049 00050 arr->heap = mem_heap_create(sizeof(dyn_block_t)); 00051 } 00052 00053 block = dyn_array_get_last_block(arr); 00054 block->used = block->used | DYN_BLOCK_FULL_FLAG; 00055 00056 heap = arr->heap; 00057 00058 block = static_cast<dyn_block_t *>(mem_heap_alloc(heap, sizeof(dyn_block_t))); 00059 00060 block->used = 0; 00061 00062 UT_LIST_ADD_LAST(list, arr->base, block); 00063 00064 return(block); 00065 }