24#include "apr_private.h"
41#if (APR_POOL_DEBUG || defined(MAKE_TABLE_PROFILE)) && APR_HAVE_STDIO_H
80 return ((
a ==
NULL) || (
a->nelts == 0));
148 if (
dst->nelts +
src->nelts >
dst->nalloc) {
178 res->elt_size * (
res->nalloc -
res->nelts));
290#if APR_CHARSET_EBCDIC
291#define CASE_MASK 0xbfbfbfbf
293#define CASE_MASK 0xdfdfdfdf
296#define TABLE_HASH_SIZE 32
297#define TABLE_INDEX_MASK 0x1f
298#define TABLE_HASH(key) (TABLE_INDEX_MASK & *(unsigned char *)(key))
299#define TABLE_INDEX_IS_INITIALIZED(t, i) ((t)->index_initialized & (1u << (i)))
300#define TABLE_SET_INDEX_INITIALIZED(t, i) ((t)->index_initialized |= (1u << (i)))
308#define COMPUTE_KEY_CHECKSUM(key, checksum) \
310 const char *k = (key); \
311 apr_uint32_t c = (apr_uint32_t)*k; \
315 c = (apr_uint32_t)*++k; \
320 c = (apr_uint32_t)*++k; \
325 c = (apr_uint32_t)*++k; \
328 checksum &= CASE_MASK; \
340#ifdef MAKE_TABLE_PROFILE
372#ifdef MAKE_TABLE_PROFILE
375 if (
t->a.nelts ==
t->a.nalloc) {
377 func ?
func :
"table_push",
t->creator,
t->a.nalloc);
381#if defined(__GNUC__) && __GNUC__ >= 2
382#define table_push(t) do_table_push(__FUNCTION__, t)
384#define table_push(t) do_table_push(NULL, t)
387#define table_push(t) ((apr_table_entry_t *) apr_array_push_noclear(&(t)->a))
397 return ((
t ==
NULL) || (
t->a.nelts == 0));
405#ifdef MAKE_TABLE_PROFILE
408 t->index_initialized = 0;
421 fprintf(
stderr,
"apr_table_copy: t's pool is not an ancestor of p\n");
427 new->a.nelts =
t->a.nelts;
430 new->index_initialized =
t->index_initialized;
441 for (
i = 0;
i < array->nelts;
i++) {
454 t->index_initialized = 0;
468 t->index_initialized = 0;
512 t->index_first[
hash] =
t->a.nelts;
565 t->index_last[
hash] =
t->a.nelts;
584 t->index_first[
hash] =
t->a.nelts;
637 t->index_last[
hash] =
t->a.nelts;
709 t->index_first[
hash] =
t->a.nelts;
728 t->index_last[
hash] =
t->a.nelts;
749 fprintf(
stderr,
"apr_table_mergen: key not in ancestor pool of t\n");
755 fprintf(
stderr,
"apr_table_mergen: val not in ancestor pool of t\n");
764 t->index_first[
hash] =
t->a.nelts;
783 t->index_last[
hash] =
t->a.nelts;
798 t->index_last[
hash] =
t->a.nelts;
800 t->index_first[
hash] =
t->a.nelts;
820 fprintf(
stderr,
"apr_table_addn: key not in ancestor pool of t\n");
824 fprintf(
stderr,
"apr_table_addn: val not in ancestor pool of t\n");
831 t->index_last[
hash] =
t->a.nelts;
833 t->index_first[
hash] =
t->a.nelts;
856 "apr_table_overlay: overlay's pool is not an ancestor of p\n");
861 "apr_table_overlay: base's pool is not an ancestor of p\n");
977 for (
i =
t->index_first[
hash];
978 rv && (
i <=
t->index_last[
hash]); ++
i) {
988 for (
i = 0; rv && (
i <
t->a.nelts); ++
i) {
1015 for (
i = 0;
i + 1 <
n;
i += 2) {
1110 if (
t->a.nelts <= 1) {
1140 if (((*sort_next)->key_checksum == (*last)->key_checksum) &&
1141 !
strcasecmp((*sort_next)->key, (*last)->key)) {
1145 ((*dup_last)->key_checksum == (*last)->key_checksum) &&
1146 !
strcasecmp((*dup_last)->key, (*last)->key)) {
1158 len += strlen((*next)->val);
1166 val_dst += strlen((*next)->val);
1180 (*last)->val = (*dup_last)->val;
1183 (*sort_next)->key =
NULL;
1209 const int n =
t->a.nelts;
1217 t->index_initialized =
s->index_initialized;
1223 t->index_last[
idx] =
s->index_last[
idx] +
n;
1225 t->index_first[
idx] =
s->index_first[
idx] +
n;
1230 t->index_initialized |=
s->index_initialized;
1236 if (
a->a.nelts +
b->a.nelts == 0) {
1244 fprintf(
stderr,
"apr_table_overlap: b's pool is not an ancestor of a's\n");
1258 if (!state->
first) {
1272 *elt = state->
first;
1294 else if (!state.
merged) {
const char apr_size_t len
APR Miscellaneous library routines.
APR general purpose library routines.
apr_array_append(apr_pool_t *p, const apr_array_header_t *first, const apr_array_header_t *second)
static void apr_table_cat(apr_table_t *t, const apr_table_t *s)
static int table_getm_do(void *v, const char *key, const char *val)
static void table_reindex(apr_table_t *t)
static apr_table_entry_t ** table_mergesort(apr_pool_t *pool, apr_table_entry_t **values, apr_size_t n)
static void * apr_array_push_noclear(apr_array_header_t *arr)
apr_array_copy_hdr(apr_pool_t *p, const apr_array_header_t *arr)
static APR_INLINE void copy_array_hdr_core(apr_array_header_t *res, const apr_array_header_t *arr)
#define COMPUTE_KEY_CHECKSUM(key, checksum)
static void make_array_core(apr_array_header_t *res, apr_pool_t *p, int nelts, int elt_size, int clear)
#define TABLE_SET_INDEX_INITIALIZED(t, i)
#define TABLE_INDEX_IS_INITIALIZED(t, i)
apr_bucket apr_bucket_brigade * a
apr_pool_t apr_dbd_t apr_dbd_results_t ** res
const char apr_ssize_t int flags
const char apr_hash_t ** values
const char int apr_pool_t * pool
int strcasecmp(const char *a, const char *b)
const apr_hash_t * overlay
APR_DECLARE_NONSTD(void) apr_terminate(void)
apr_interval_time_t apr_pollcb_cb_t func
#define apr_pcalloc(p, size)
void apr_skiplistnode apr_skiplist_compare comp
const apr_array_header_t * arr
#define APR_OVERLAP_TABLES_MERGE
int() apr_table_do_callback_fn_t(void *rec, const char *key, const char *value)
void const apr_table_t void const apr_table_t va_list vp
const apr_array_header_t * first
const apr_array_header_t const apr_array_header_t * second
#define APR_OVERLAP_TABLES_ADD
apr_uint32_t key_checksum
apr_uint32_t index_initialized
apr_array_header_t * merged
typedef int(WSAAPI *apr_winapi_fpt_WSAPoll)(IN OUT LPWSAPOLLFD fdArray