mariadb/ut/ut0vec.c
marko 1d1dc31a06 branches/zip: Introduce UNIV_INTERN, a linkage specifier for InnoDB-global
symbols.  Use it for all definitions of non-static variables and functions.

lexyy.c, make_flex.sh: Declare yylex as UNIV_INTERN, not static.  It is
referenced from pars0grm.c.

Actually, according to
	nm .libs/ha_innodb.so|grep -w '[ABCE-TVXYZ]'
the following symbols are still global:

* The vtable for class ha_innodb
* pars0grm.c: The function yyparse() and the variables yychar, yylval, yynerrs

The required changes to the Bison-generated file pars0grm.c will be addressed
in a separate commit, which will add a script similar to make_flex.sh.

The class ha_innodb is renamed from class ha_innobase by a #define.  Thus,
there will be no clash with the builtin InnoDB.  However, there will be some
overhead for invoking virtual methods of class ha_innodb.  Ideas for making
the vtable hidden are welcome.  -fvisibility=hidden is not available in GCC 3.
2008-02-06 14:17:36 +00:00

54 lines
1.1 KiB
C

#include "ut0vec.h"
#ifdef UNIV_NONINL
#include "ut0vec.ic"
#endif
#include <string.h>
/********************************************************************
Create a new vector with the given initial size. */
UNIV_INTERN
ib_vector_t*
ib_vector_create(
/*=============*/
/* out: vector */
mem_heap_t* heap, /* in: heap */
ulint size) /* in: initial size */
{
ib_vector_t* vec;
ut_a(size > 0);
vec = mem_heap_alloc(heap, sizeof(*vec));
vec->heap = heap;
vec->data = mem_heap_alloc(heap, sizeof(void*) * size);
vec->used = 0;
vec->total = size;
return(vec);
}
/********************************************************************
Push a new element to the vector, increasing its size if necessary. */
UNIV_INTERN
void
ib_vector_push(
/*===========*/
ib_vector_t* vec, /* in: vector */
void* elem) /* in: data element */
{
if (vec->used >= vec->total) {
void** new_data;
ulint new_total = vec->total * 2;
new_data = mem_heap_alloc(vec->heap,
sizeof(void*) * new_total);
memcpy(new_data, vec->data, sizeof(void*) * vec->total);
vec->data = new_data;
vec->total = new_total;
}
vec->data[vec->used] = elem;
vec->used++;
}