You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.8 KiB

  1. /*****************************************************************************
  2. Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
  3. This program is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU General Public License as published by the Free Software
  5. Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along with
  10. this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  11. Place, Suite 330, Boston, MA 02111-1307 USA
  12. *****************************************************************************/
  13. /**************************************************//**
  14. @file dyn/dyn0dyn.c
  15. The dynamically allocated array
  16. Created 2/5/1996 Heikki Tuuri
  17. *******************************************************/
  18. #include "dyn0dyn.h"
  19. #ifdef UNIV_NONINL
  20. #include "dyn0dyn.ic"
  21. #endif
  22. /************************************************************//**
  23. Adds a new block to a dyn array.
  24. @return created block */
  25. UNIV_INTERN
  26. dyn_block_t*
  27. dyn_array_add_block(
  28. /*================*/
  29. dyn_array_t* arr) /*!< in: dyn array */
  30. {
  31. mem_heap_t* heap;
  32. dyn_block_t* block;
  33. ut_ad(arr);
  34. ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
  35. if (arr->heap == NULL) {
  36. UT_LIST_INIT(arr->base);
  37. UT_LIST_ADD_FIRST(list, arr->base, arr);
  38. arr->heap = mem_heap_create(sizeof(dyn_block_t));
  39. }
  40. block = dyn_array_get_last_block(arr);
  41. block->used = block->used | DYN_BLOCK_FULL_FLAG;
  42. heap = arr->heap;
  43. block = mem_heap_alloc(heap, sizeof(dyn_block_t));
  44. block->used = 0;
  45. UT_LIST_ADD_LAST(list, arr->base, block);
  46. return(block);
  47. }