|
htils 1
A small set of utilities for C programming.
|
Go to the source code of this file.
Data Structures | |
| struct | h2o_da_header |
| The header of a dynamic array. More... | |
Macros | |
| #define | H2O_DA_HEADER_SIZE |
| #define | h2o_da_len(darray) ((darray) ? h2o_da__hdr(darray)->len : 0) |
| #define | h2o_da_cap(darray) ((darray) ? h2o_da__hdr(darray)->cap : 0) |
| #define | h2o_da_new(pool, darray, intitial_capacity) |
| Initialize a dynamic array. | |
| #define | h2o_da_append(pool, darray, item) |
| Append an item to a dynamic array. | |
| #define | h2o_da_pop(darray) |
| Pop an item from a dynamic array. | |
| #define | h2o_da_last(darray) |
| Substitute with the last item in a dynamic array. | |
| #define | h2o_da_clear(darray) |
| Clears a dynamic array. | |
Typedefs | |
| typedef struct h2o_da_header | h2o_da_header_t |
| The header of a dynamic array. | |
Functions | |
| static h2o_da_header_t * | h2o_da__hdr (void *h2o_da) |
| Get the dynamic array header. | |
| #define h2o_da_append | ( | pool, | |
| darray, | |||
| item | |||
| ) |
Append an item to a dynamic array.
By incrementing the len, has automatic capacity growing functionality.
| pool | The memory pool to allocate the dynamic array from. |
| darray | The dynamic array to append to. |
| item | The item to append to the dynamic array. |
pool, darray, and item must be valid and cannot be null. | #define h2o_da_cap | ( | darray | ) | ((darray) ? h2o_da__hdr(darray)->cap : 0) |
Gets the capacity of the current dynamic array
| #define h2o_da_clear | ( | darray | ) |
Clears a dynamic array.
By setting its length to 0, if the dynamic array is null, nothing happens.
| darray | The dynamic array to clear. |
| #define H2O_DA_HEADER_SIZE |
The size of the header of a dynamic array.
| #define h2o_da_last | ( | darray | ) |
Substitute with the last item in a dynamic array.
Asserts that the length of the dynamic array is larger than 0, then simply gets the last entry.
| darray | The dynamic array to get the last item from. |
| #define h2o_da_len | ( | darray | ) | ((darray) ? h2o_da__hdr(darray)->len : 0) |
Gets the length of the current dynamic array
| #define h2o_da_new | ( | pool, | |
| darray, | |||
| intitial_capacity | |||
| ) |
Initialize a dynamic array.
Caluclates the size for the header with H2O_DA_HEADER_SIZE, and the capacity; Allocates the header with initial_capacity, then sets the dynamic array to be the header + 1 offsetting the header.
| pool | The memory pool to allocate the dynamic array from. |
| darray | The dynamic array to initialize. |
| intitial_capacity | The initial capacity of the dynamic array. |
pool, and darray must be valid and cannot be null.intitial_capacity must be greater than 0. | #define h2o_da_pop | ( | darray | ) |
Pop an item from a dynamic array.
By simply decrementing its length, if the dynamic array is empty, nothing happens.
| darray | The dynamic array to pop from. |
| typedef struct h2o_da_header h2o_da_header_t |
The header of a dynamic array.
| cap | The capacity of the dynamic array. |
| len | The length of the dynamic array. |
|
inlinestatic |
Get the dynamic array header.
Casts the da to cstr * from a dynamic array, by then offsetting by the size of it.
| da | The dynamic array to get the header from. |
da must be valid and cannot be null.