MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dyn0dyn.h File Reference
#include "univ.i"
#include "ut0lst.h"
#include "mem0mem.h"
#include "dyn0dyn.ic"
Include dependency graph for dyn0dyn.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dyn_block_t
 A block in a dynamically allocated array. NOTE! Do not access the fields of the struct directly: the definition appears here only for the compiler to know its size! More...

Macros

#define DYN_ARRAY_DATA_SIZE   512
#define dyn_array_get_first_block(arr)   (arr)
#define dyn_array_get_last_block(arr)   ((arr)->heap ? UT_LIST_GET_LAST((arr)->base) : (arr))
#define dyn_array_get_next_block(arr, block)   ((arr)->heap ? UT_LIST_GET_NEXT(list, block) : NULL)
#define dyn_array_get_prev_block(arr, block)   ((arr)->heap ? UT_LIST_GET_PREV(list, block) : NULL)

Typedefs

typedef dyn_block_t dyn_array_t

Functions

UNIV_INLINE dyn_array_tdyn_array_create (dyn_array_t *arr) __attribute__((nonnull))
UNIV_INLINE void dyn_array_free (dyn_array_t *arr) __attribute__((nonnull))
UNIV_INLINE byte * dyn_array_open (dyn_array_t *arr, ulint size) __attribute__((nonnull
UNIV_INLINE void dyn_array_close (dyn_array_t *arr, const byte *ptr) __attribute__((nonnull))
UNIV_INLINE void * dyn_array_push (dyn_array_t *arr, ulint size) __attribute__((nonnull
UNIV_INLINE void * dyn_array_get_element (const dyn_array_t *arr, ulint pos) __attribute__((nonnull
UNIV_INLINE ulint dyn_array_get_data_size (const dyn_array_t *arr) __attribute__((nonnull
UNIV_INLINE ulint dyn_block_get_used (const dyn_block_t *block) __attribute__((nonnull
UNIV_INLINE byte * dyn_block_get_data (const dyn_block_t *block) __attribute__((nonnull
UNIV_INLINE void dyn_push_string (dyn_array_t *arr, const byte *str, ulint len) __attribute__((nonnull))

Variables

UNIV_INLINE byte warn_unused_result
UNIV_INLINE ulint pure

Detailed Description

The dynamically allocated array

Created 2/5/1996 Heikki Tuuri

Definition in file dyn0dyn.h.

Macro Definition Documentation

#define DYN_ARRAY_DATA_SIZE   512
This is the initial 'payload' size of a dynamic array;

this must be > MLOG_BUF_MARGIN + 30!

Definition at line 40 of file dyn0dyn.h.

#define dyn_array_get_first_block (   arr)    (arr)

Gets the first block in a dyn array.

Parameters
arrdyn array
Returns
first block

Definition at line 118 of file dyn0dyn.h.

#define dyn_array_get_last_block (   arr)    ((arr)->heap ? UT_LIST_GET_LAST((arr)->base) : (arr))

Gets the last block in a dyn array.

Parameters
arrdyn array
Returns
last block

Definition at line 123 of file dyn0dyn.h.

#define dyn_array_get_next_block (   arr,
  block 
)    ((arr)->heap ? UT_LIST_GET_NEXT(list, block) : NULL)

Gets the next block in a dyn array.

Parameters
arrdyn array
blockdyn array block
Returns
pointer to next, NULL if end of list

Definition at line 130 of file dyn0dyn.h.

#define dyn_array_get_prev_block (   arr,
  block 
)    ((arr)->heap ? UT_LIST_GET_PREV(list, block) : NULL)

Gets the previous block in a dyn array.

Parameters
arrdyn array
blockdyn array block
Returns
pointer to previous, NULL if end of list

Definition at line 137 of file dyn0dyn.h.

Typedef Documentation

Dynamically allocated array

Definition at line 34 of file dyn0dyn.h.

Function Documentation

UNIV_INLINE void dyn_array_close ( dyn_array_t arr,
const byte *  ptr 
)

Closes the buffer returned by dyn_array_open.

Parameters
arrin: dynamic array
ptrin: end of used space
UNIV_INLINE dyn_array_t* dyn_array_create ( dyn_array_t arr)

Initializes a dynamic array.

Returns
initialized dyn array
Parameters
arrin/out memory buffer of size sizeof(dyn_array_t)
UNIV_INLINE void dyn_array_free ( dyn_array_t arr)

Frees a dynamic array.

Parameters
arrin,own: dyn array

Here is the caller graph for this function:

UNIV_INLINE ulint dyn_array_get_data_size ( const dyn_array_t arr)

Returns the size of stored data in a dyn array.

Returns
data size in bytes
Parameters
arrin: dyn array

Here is the caller graph for this function:

UNIV_INLINE void* dyn_array_get_element ( const dyn_array_t arr,
ulint  pos 
)

Returns pointer to an element in dyn array.

Returns
pointer to element
Parameters
arrin: dyn array
posin: position of element in bytes from array start
UNIV_INLINE byte* dyn_array_open ( dyn_array_t arr,
ulint  size 
)

Makes room on top of a dyn array and returns a pointer to a buffer in it. After copying the elements, the caller must close the buffer using dyn_array_close.

Returns
pointer to the buffer
Parameters
arrin: dynamic array
sizein: size in bytes of the buffer; MUST be smaller than DYN_ARRAY_DATA_SIZE!
UNIV_INLINE void* dyn_array_push ( dyn_array_t arr,
ulint  size 
)

Makes room on top of a dyn array and returns a pointer to the added element. The caller must copy the element to the pointer returned.

Returns
pointer to the element
Parameters
arrin/out: dynamic array
sizein: size in bytes of the element
UNIV_INLINE byte* dyn_block_get_data ( const dyn_block_t block)

Gets pointer to the start of data in a dyn array block.

Returns
pointer to data
Parameters
blockin: dyn array block

Here is the caller graph for this function:

UNIV_INLINE ulint dyn_block_get_used ( const dyn_block_t block)

Gets the number of used bytes in a dyn array block.

Returns
number of bytes used
Parameters
blockin: dyn array block

Here is the caller graph for this function:

UNIV_INLINE void dyn_push_string ( dyn_array_t arr,
const byte *  str,
ulint  len 
)

Pushes n bytes to a dyn array.

Parameters
arrin/out: dyn array
strin: string to write
lenin: string length

Here is the caller graph for this function: