~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/ut0vec.h

  • Committer: Brian Aker
  • Date: 2010-05-27 01:25:56 UTC
  • mfrom: (1567.1.4 new-staging)
  • Revision ID: brian@gaz-20100527012556-5zgkirkl7swbigd6
Merge of Brian, Paul. PBXT compile issue, and test framework cleanup. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef IB_VECTOR_H
2
 
#define IB_VECTOR_H
3
 
 
4
 
#include "univ.i"
5
 
#include "mem0mem.h"
6
 
 
7
 
typedef struct ib_vector_struct ib_vector_t;
8
 
 
9
 
/* An automatically resizing vector datatype with the following properties:
10
 
 
11
 
 -Contains void* items.
12
 
 
13
 
 -The items are owned by the caller.
14
 
 
15
 
 -All memory allocation is done through a heap owned by the caller, who is
16
 
 responsible for freeing it when done with the vector.
17
 
 
18
 
 -When the vector is resized, the old memory area is left allocated since it
19
 
 uses the same heap as the new memory area, so this is best used for
20
 
 relatively small or short-lived uses.
21
 
*/
22
 
 
23
 
/********************************************************************
24
 
Create a new vector with the given initial size. */
25
 
 
26
 
ib_vector_t*
27
 
ib_vector_create(
28
 
/*=============*/
29
 
                                /* out: vector */
30
 
        mem_heap_t*     heap,   /* in: heap */
31
 
        ulint           size);  /* in: initial size */
32
 
 
33
 
/********************************************************************
34
 
Push a new element to the vector, increasing its size if necessary. */
35
 
 
36
 
void
37
 
ib_vector_push(
38
 
/*===========*/
39
 
        ib_vector_t*    vec,    /* in: vector */
40
 
        void*           elem);  /* in: data element */
41
 
 
42
 
/********************************************************************
43
 
Get the number of elements in the vector. */
44
 
UNIV_INLINE
45
 
ulint
46
 
ib_vector_size(
47
 
/*===========*/
48
 
                                /* out: number of elements in vector */
49
 
        ib_vector_t*    vec);   /* in: vector */
50
 
 
51
 
/********************************************************************
52
 
Get the n'th element. */
53
 
UNIV_INLINE
54
 
void*
55
 
ib_vector_get(
56
 
/*==========*/
57
 
                                /* out: n'th element */
58
 
        ib_vector_t*    vec,    /* in: vector */
59
 
        ulint           n);     /* in: element index to get */
60
 
 
61
 
/* See comment at beginning of file. */
62
 
struct ib_vector_struct {
63
 
        mem_heap_t*     heap;   /* heap */
64
 
        void**          data;   /* data elements */
65
 
        ulint           used;   /* number of elements currently used */
66
 
        ulint           total;  /* number of elements allocated */
67
 
};
68
 
 
69
 
#ifndef UNIV_NONINL
70
 
#include "ut0vec.ic"
71
 
#endif
72
 
 
73
 
#endif