summaryrefslogtreecommitdiff
path: root/storage/innobase/include/ut0vec.ic
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/ut0vec.ic')
-rw-r--r--storage/innobase/include/ut0vec.ic97
1 files changed, 11 insertions, 86 deletions
diff --git a/storage/innobase/include/ut0vec.ic b/storage/innobase/include/ut0vec.ic
index f41a85e1d1d..17f4df579b6 100644
--- a/storage/innobase/include/ut0vec.ic
+++ b/storage/innobase/include/ut0vec.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2006, 2009, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2006, 2014, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -23,6 +23,8 @@ A vector of pointers to data items
Created 4/6/2006 Osku Salerma
************************************************************************/
+#include "ut0new.h"
+
#define IB_VEC_OFFSET(v, i) (vec->sizeof_value * i)
/********************************************************************
@@ -54,6 +56,7 @@ ib_heap_free(
/********************************************************************
The default ib_vector_t heap resize. Since we can't resize the heap
we have to copy the elements from the old ptr to the new ptr.
+We always assume new_size >= old_size, so the buffer won't overflow.
Uses mem_heap_alloc(). */
UNIV_INLINE
void*
@@ -67,6 +70,7 @@ ib_heap_resize(
void* new_ptr;
mem_heap_t* heap = (mem_heap_t*) allocator->arg;
+ ut_a(new_size >= old_size);
new_ptr = mem_heap_alloc(heap, new_size);
memcpy(new_ptr, old_ptr, old_size);
@@ -105,74 +109,6 @@ ib_heap_allocator_free(
}
/********************************************************************
-Wrapper around ut_malloc(). */
-UNIV_INLINE
-void*
-ib_ut_malloc(
-/*=========*/
- ib_alloc_t* allocator UNIV_UNUSED, /* in: allocator */
- ulint size) /* in: size in bytes */
-{
- return(ut_malloc(size));
-}
-
-/********************************************************************
-Wrapper around ut_free(). */
-UNIV_INLINE
-void
-ib_ut_free(
-/*=======*/
- ib_alloc_t* allocator UNIV_UNUSED, /* in: allocator */
- void* ptr) /* in: size in bytes */
-{
- ut_free(ptr);
-}
-
-/********************************************************************
-Wrapper aroung ut_realloc(). */
-UNIV_INLINE
-void*
-ib_ut_resize(
-/*=========*/
- ib_alloc_t* allocator UNIV_UNUSED, /* in: allocator */
- void* old_ptr, /* in: pointer to memory */
- ulint old_size UNIV_UNUSED,/* in: old size in bytes */
- ulint new_size) /* in: new size in bytes */
-{
- return(ut_realloc(old_ptr, new_size));
-}
-
-/********************************************************************
-Create a ut allocator. */
-UNIV_INLINE
-ib_alloc_t*
-ib_ut_allocator_create(void)
-/*========================*/
-{
- ib_alloc_t* ib_ut_alloc;
-
- ib_ut_alloc = (ib_alloc_t*) ut_malloc(sizeof(*ib_ut_alloc));
-
- ib_ut_alloc->arg = NULL;
- ib_ut_alloc->mem_release = ib_ut_free;
- ib_ut_alloc->mem_malloc = ib_ut_malloc;
- ib_ut_alloc->mem_resize = ib_ut_resize;
-
- return(ib_ut_alloc);
-}
-
-/********************************************************************
-Free a ut allocator. */
-UNIV_INLINE
-void
-ib_ut_allocator_free(
-/*=================*/
- ib_alloc_t* ib_ut_alloc) /* in: alloc instace to free */
-{
- ut_free(ib_ut_alloc);
-}
-
-/********************************************************************
Get number of elements in vector. */
UNIV_INLINE
ulint
@@ -214,7 +150,7 @@ ib_vector_get_const(
}
/****************************************************************//**
Get last element. The vector must not be empty.
-@return last element */
+@return last element */
UNIV_INLINE
void*
ib_vector_get_last(
@@ -286,7 +222,7 @@ ib_vector_last_const(
/****************************************************************//**
Remove the last element from the vector.
-@return last vector element */
+@return last vector element */
UNIV_INLINE
void*
ib_vector_pop(
@@ -392,24 +328,13 @@ ib_vector_free(
/*===========*/
ib_vector_t* vec) /* in, own: vector */
{
- /* Currently we only support two types of allocators, heap
- and ut_malloc(), when the heap is freed all the elements are
- freed too. With ut allocator, we need to free the elements,
- the vector instance and the allocator separately. */
+ /* Currently we only support one type of allocator - heap,
+ when the heap is freed all the elements are freed too. */
/* Only the heap allocator uses the arg field. */
- if (vec->allocator->arg) {
- mem_heap_free((mem_heap_t*) vec->allocator->arg);
- } else {
- ib_alloc_t* allocator;
-
- allocator = vec->allocator;
+ ut_ad(vec->allocator->arg != NULL);
- allocator->mem_release(allocator, vec->data);
- allocator->mem_release(allocator, vec);
-
- ib_ut_allocator_free(allocator);
- }
+ mem_heap_free((mem_heap_t*) vec->allocator->arg);
}
/********************************************************************