Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Typedefs | Functions | Variables
st.c File Reference
`#include "ruby/ruby.h"`
`#include <stdio.h>`
`#include <string.h>`
Include dependency graph for st.c:

Go to the source code of this file.

## Data Structures
struct | st_table_entry
struct | st_packed_entry

## Macros
#define | STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[(expr) ? 1 : -1];
#define | ST_DEFAULT_MAX_DENSITY 5
#define | ST_DEFAULT_INIT_TABLE_SIZE 11
#define | ST_DEFAULT_SECOND_TABLE_SIZE 19
#define | ST_DEFAULT_PACKED_TABLE_SIZE 18
#define | PACKED_UNIT (int)(sizeof(st_packed_entry) / sizeof(st_table_entry*))
#define | MAX_PACKED_HASH (int)(ST_DEFAULT_PACKED_TABLE_SIZE * sizeof(st_table_entry*) / sizeof(st_packed_entry))
#define | type_numhash st_hashtype_num
#define | malloc xmalloc
#define | calloc xcalloc
#define | realloc xrealloc
#define | free(x) xfree(x)
#define | numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
#define | EQUAL(table, x, y) ((x)==(y) || (*(table)->type->compare)((x),(y)) == 0)
#define | do_hash(key, table) (st_index_t)(*(table)->type->hash)((key))
#define | do_hash_bin(key, table) (do_hash((key), (table))%(table)->num_bins)
#define | st_alloc_entry() (st_table_entry *)malloc(sizeof(st_table_entry))
#define | st_free_entry(entry) free(entry)
#define | st_alloc_table() (st_table *)malloc(sizeof(st_table))
#define | st_dealloc_table(table) free(table)
#define | st_alloc_bins(size) (st_table_entry **)calloc(size, sizeof(st_table_entry *))
#define | st_free_bins(bins, size) free(bins)
#define | bins as.big.bins
#define | head as.big.head
#define | tail as.big.tail
#define | real_entries as.packed.real_entries
#define | PACKED_BINS(table) ((table)->as.packed.entries)
#define | PACKED_ENT(table, i) PACKED_BINS(table)[i]
#define | PKEY(table, i) PACKED_ENT((table), (i)).key
#define | PVAL(table, i) PACKED_ENT((table), (i)).val
#define | PHASH(table, i) PACKED_ENT((table), (i)).hash
#define | PKEY_SET(table, i, v) (PKEY((table), (i)) = (v))
#define | PVAL_SET(table, i, v) (PVAL((table), (i)) = (v))
#define | PHASH_SET(table, i, v) (PHASH((table), (i)) = (v))
#define | MINSIZE 8
#define | PTR_NOT_EQUAL(table, ptr, hash_val, key) ((ptr) != 0 && ((ptr)->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
#define | COLLISION
#define | FOUND_ENTRY
#define | FIND_ENTRY(table, ptr, hash_val, bin_pos) ((ptr) = find_entry((table), key, (hash_val), ((bin_pos) = (hash_val)%(table)->num_bins)))
#define | collision_check 0
#define | collision_check 1
#define | FNV1_32A_INIT 0x811c9dc5
#define | FNV_32_PRIME 0x01000193
#define | UNALIGNED_WORD_ACCESS 0
#define | MURMUR 2
#define | MurmurMagic_1 (st_index_t)0xc6a4a793
#define | MurmurMagic_2 (st_index_t)0x5bd1e995
#define | MurmurMagic MurmurMagic_2
#define | murmur_step(h, k) murmur((h), (k), 16)
#define | murmur1(h) murmur_step((h), 24)
#define | data_at(n) (st_index_t)((unsigned char)data[(n)])
#define | UNALIGNED_ADD_4 UNALIGNED_ADD(2); UNALIGNED_ADD(1); UNALIGNED_ADD(0)
#define | UNALIGNED_ADD_ALL UNALIGNED_ADD_4
#define | UNALIGNED_ADD(n)

## Typedefs
typedef struct st_table_entry | st_table_entry
typedef struct st_packed_entry | st_packed_entry

## Functions
| STATIC_ASSERT (st_packed_entry, sizeof(st_packed_entry)==sizeof(st_table_entry *[PACKED_UNIT]))
static st_index_t | strhash (st_data_t)
static st_index_t | strcasehash (st_data_t)
static void | rehash (st_table *)
static st_table_entry ** | st_realloc_bins (st_table_entry **bins, st_index_t newsize, st_index_t oldsize)
static void | remove_packed_entry (st_table *table, st_index_t i)
static void | remove_safe_packed_entry (st_table *table, st_index_t i, st_data_t never)
static st_index_t | new_size (st_index_t size)
st_table * | st_init_table_with_size (const struct st_hash_type *type, st_index_t size)
st_table * | st_init_table (const struct st_hash_type *type)
st_table * | st_init_numtable (void)
st_table * | st_init_numtable_with_size (st_index_t size)
st_table * | st_init_strtable (void)
st_table * | st_init_strtable_with_size (st_index_t size)
st_table * | st_init_strcasetable (void)
st_table * | st_init_strcasetable_with_size (st_index_t size)
void | st_clear (st_table *table)
void | st_free_table (st_table *table)
size_t | st_memsize (const st_table *table)
static st_table_entry * | find_entry (st_table *table, st_data_t key, st_index_t hash_val, st_index_t bin_pos)
static st_index_t | find_packed_index (st_table *table, st_index_t hash_val, st_data_t key)
int | st_lookup (st_table *table, register st_data_t key, st_data_t *value)
int | st_get_key (st_table *table, register st_data_t key, st_data_t *result)
static st_table_entry * | new_entry (st_table *table, st_data_t key, st_data_t value, st_index_t hash_val, register st_index_t bin_pos)
static void | add_direct (st_table *table, st_data_t key, st_data_t value, st_index_t hash_val, register st_index_t bin_pos)
static void | unpack_entries (register st_table *table)
static void | add_packed_direct (st_table *table, st_data_t key, st_data_t value, st_index_t hash_val)
int | st_insert (register st_table *table, register st_data_t key, st_data_t value)
int | st_insert2 (register st_table *table, register st_data_t key, st_data_t value, st_data_t(*func)(st_data_t))
void | st_add_direct (st_table *table, st_data_t key, st_data_t value)
static void | rehash (register st_table *table)
st_table * | st_copy (st_table *old_table)
static void | remove_entry (st_table *table, st_table_entry *ptr)
int | st_delete (register st_table *table, register st_data_t *key, st_data_t *value)
int | st_delete_safe (register st_table *table, register st_data_t *key, st_data_t *value, st_data_t never)
void | st_cleanup_safe (st_table *table, st_data_t never)
int | st_update (st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg)
int | st_foreach_check (st_table *table, int(*func)(ANYARGS), st_data_t arg, st_data_t never)
int | st_foreach (st_table *table, int(*func)(ANYARGS), st_data_t arg)
static st_index_t | murmur (st_index_t h, st_index_t k, int r)
static st_index_t | murmur_finish (st_index_t h)
st_index_t | st_hash (const void *ptr, size_t len, st_index_t h)
st_index_t | st_hash_uint32 (st_index_t h, uint32_t i)
st_index_t | st_hash_uint (st_index_t h, st_index_t i)
st_index_t | st_hash_end (st_index_t h)
st_index_t | st_hash_start (st_index_t h)
int | st_strcasecmp (const char *s1, const char *s2)
int | st_strncasecmp (const char *s1, const char *s2, size_t n)
int | st_numcmp (st_data_t x, st_data_t y)
st_index_t | st_numhash (st_data_t n)

## Variables
static struct st_hash_type | type_strhash
static struct st_hash_type | type_strcasehash
static const unsigned int | primes []

## Macro Definition Documentation

#define bins as.big.bins

Definition at line 106 of file st.c.

Referenced by st_realloc_bins().

#define calloc xcalloc

Definition at line 78 of file st.c.

#define COLLISION

Definition at line 373 of file st.c.

Referenced by find_entry().

#define collision_check 0

Definition at line 465 of file st.c.

#define collision_check 1

Definition at line 465 of file st.c.

#define data_at | ( |  | n | ) | (st_index_t)((unsigned char)data[(n)])

#define do_hash | ( |  | key,
|  |  | table
| ) |  | (st_index_t)(*(table)->type->hash)((key))

Definition at line 87 of file st.c.

Referenced by st_add_direct(), st_delete(), st_delete_safe(), st_get_key(), st_insert(), st_insert2(), st_lookup(), and st_update().

#define do_hash_bin | ( |  | key,
|  |  | table
| ) |  | (do_hash((key), (table))%(table)->num_bins)

Definition at line 88 of file st.c.

#define EQUAL | ( |  | table,
|  |  | x,
|  |  | y
| ) |  | ((x)==(y) || (*(table)->type->compare)((x),(y)) == 0)

Definition at line 85 of file st.c.

Referenced by find_packed_index(), st_delete(), and st_delete_safe().

#define FIND_ENTRY | ( |  | table,
|  |  | ptr,
|  |  | hash_val,
|  |  | bin_pos
| ) |  | ((ptr) = find_entry((table), key, (hash_val), ((bin_pos) = (hash_val)%(table)->num_bins)))

Definition at line 377 of file st.c.

Referenced by st_foreach(), st_foreach_check(), st_insert(), st_insert2(), and st_update().

#define FNV1_32A_INIT 0x811c9dc5

Definition at line 1215 of file st.c.

Referenced by strcasehash(), and strhash().

#define FNV_32_PRIME 0x01000193

Definition at line 1220 of file st.c.

Referenced by strcasehash().

#define FOUND_ENTRY

Definition at line 374 of file st.c.

Referenced by find_entry().

#define free | ( |  | x | ) | xfree(x)

Definition at line 80 of file st.c.

#define head as.big.head

Definition at line 107 of file st.c.

Referenced by ary_ensure_room_for_unshift(), block_append_gen(), divide_look_behind_alternatives(), fixup_nodes(), gzfile_read_header(), iseq_compile_each(), list_concat_gen(), literal_concat_gen(), new_evstr_gen(), onig_chain_reduce(), start_document(), and switch().

#define malloc xmalloc

Definition at line 77 of file st.c.

#define MAX_PACKED_HASH (int)(ST_DEFAULT_PACKED_TABLE_SIZE * sizeof(st_table_entry*) / sizeof(st_packed_entry))

Definition at line 40 of file st.c.

Referenced by st_init_table_with_size(), and unpack_entries().

#define MINSIZE 8

Definition at line 146 of file st.c.

Referenced by new_size().

#define MURMUR 2

Definition at line 1256 of file st.c.

#define murmur1 | ( |  | h | ) | murmur_step((h), 24)

Definition at line 1309 of file st.c.

Referenced by st_hash_uint().

#define murmur_step | ( |  | h,
|  |  | k
| ) |  | murmur((h), (k), 16)

Definition at line 1304 of file st.c.

Referenced by st_hash(), st_hash_end(), and st_hash_uint32().

#define MurmurMagic MurmurMagic_2

Definition at line 1267 of file st.c.

Referenced by murmur(), murmur_finish(), and st_hash().

#define MurmurMagic_1 (st_index_t)0xc6a4a793

Definition at line 1259 of file st.c.

#define MurmurMagic_2 (st_index_t)0x5bd1e995

Definition at line 1260 of file st.c.

#define numberof | ( |  | array | ) | (int)(sizeof(array) / sizeof((array)[0]))

Definition at line 83 of file st.c.

Referenced by new_size().

#define PACKED_BINS | ( |  | table | ) | ((table)->as.packed.entries)

Definition at line 112 of file st.c.

Referenced by unpack_entries().

#define PACKED_ENT | ( |  | table,
|  |  | i
| ) |  | PACKED_BINS(table)[i]

Definition at line 113 of file st.c.

Referenced by remove_packed_entry(), and st_cleanup_safe().

#define PACKED_UNIT (int)(sizeof(st_packed_entry) / sizeof(st_table_entry*))

Definition at line 39 of file st.c.

#define PHASH | ( |  | table,
|  |  | i
| ) |  | PACKED_ENT((table), (i)).hash

Definition at line 116 of file st.c.

Referenced by find_packed_index(), st_foreach(), and st_foreach_check().

#define PHASH_SET | ( |  | table,
|  |  | i,
|  |  | v
| ) |  | (PHASH((table), (i)) = (v))

Definition at line 119 of file st.c.

Referenced by add_packed_direct(), and remove_safe_packed_entry().

#define PKEY | ( |  | table,
|  |  | i
| ) |  | PACKED_ENT((table), (i)).key

Definition at line 114 of file st.c.

Referenced by find_packed_index(), st_cleanup_safe(), st_delete(), st_delete_safe(), st_foreach(), st_foreach_check(), st_get_key(), and st_update().

#define PKEY_SET | ( |  | table,
|  |  | i,
|  |  | v
| ) |  | (PKEY((table), (i)) = (v))

Definition at line 117 of file st.c.

Referenced by add_packed_direct(), and remove_safe_packed_entry().

#define PTR_NOT_EQUAL | ( |  | table,
|  |  | ptr,
|  |  | hash_val,
|  |  | key
| ) |  | ((ptr) != 0 && ((ptr)->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))

Definition at line 352 of file st.c.

Referenced by find_entry().

#define PVAL | ( |  | table,
|  |  | i
| ) |  | PACKED_ENT((table), (i)).val

Definition at line 115 of file st.c.

Referenced by st_delete(), st_delete_safe(), st_foreach(), st_foreach_check(), st_lookup(), and st_update().

#define PVAL_SET | ( |  | table,
|  |  | i,
|  |  | v
| ) |  | (PVAL((table), (i)) = (v))

Definition at line 118 of file st.c.

Referenced by add_packed_direct(), remove_safe_packed_entry(), st_insert(), st_insert2(), and st_update().

#define real_entries as.packed.real_entries

Definition at line 109 of file st.c.

Referenced by find_packed_index(), remove_packed_entry(), st_delete(), st_delete_safe(), st_get_key(), st_insert(), st_insert2(), st_lookup(), and st_update().

#define realloc xrealloc

Definition at line 79 of file st.c.

#define st_alloc_bins | ( |  | size | ) | (st_table_entry **)calloc(size, sizeof(st_table_entry *))

Definition at line 95 of file st.c.

Referenced by st_copy(), and st_init_table_with_size().

#define st_alloc_entry | ( |  | ) | (st_table_entry *)malloc(sizeof(st_table_entry))

Definition at line 91 of file st.c.

Referenced by new_entry(), and st_copy().

#define st_alloc_table | ( |  | ) | (st_table *)malloc(sizeof(st_table))

Definition at line 93 of file st.c.

Referenced by st_copy(), and st_init_table_with_size().

#define st_dealloc_table | ( |  | table | ) | free(table)

Definition at line 94 of file st.c.

Referenced by st_copy(), and st_free_table().

#define ST_DEFAULT_INIT_TABLE_SIZE 11

Definition at line 36 of file st.c.

Referenced by unpack_entries().

#define ST_DEFAULT_MAX_DENSITY 5

Definition at line 35 of file st.c.

Referenced by add_direct().

#define ST_DEFAULT_PACKED_TABLE_SIZE 18

Definition at line 38 of file st.c.

Referenced by st_init_table_with_size().

#define ST_DEFAULT_SECOND_TABLE_SIZE 19

Definition at line 37 of file st.c.

#define st_free_bins | ( |  | bins,
|  |  | size
| ) |  | free(bins)

Definition at line 96 of file st.c.

Referenced by st_free_table().

#define st_free_entry | ( |  | entry | ) | free(entry)

Definition at line 92 of file st.c.

Referenced by st_cleanup_safe(), st_clear(), st_delete(), st_foreach(), and st_update().

#define STATIC_ASSERT | ( |  | name,
|  |  | expr
| ) |  | typedef int static_assert_##name##_check[(expr) ? 1 : -1];

Definition at line 33 of file st.c.

#define tail as.big.tail

Definition at line 108 of file st.c.

Referenced by block_append_gen(), bm_search(), bm_search_ic(), bm_search_notrev(), bm_search_notrev_ic(), cmdglob(), error_print(), glob_make_pattern(), insert(), list_concat_gen(), literal_concat_gen(), new_args_gen(), rb_file_join(), rb_w32_cmdvector(), and start_document().

#define type_numhash st_hashtype_num

Referenced by st_init_numtable(), and st_init_numtable_with_size().

#define UNALIGNED_ADD | ( |  | n | ) |

Value:
case SIZEOF_ST_INDEX_T - (n) - 1: \
t |= data_at(n) << CHAR_BIT*(n)
n
ssize_t n
Definition: bigdecimal.c:5655
SIZEOF_ST_INDEX_T
#define SIZEOF_ST_INDEX_T
CHAR_BIT
#define CHAR_BIT
Definition: ruby.h:208
t
int t
Definition: ripper.c:14699
data_at
#define data_at(n)

#define UNALIGNED_ADD | ( |  | n | ) |

Value:
case (n) + 1: \
d |= data_at(n) << CHAR_BIT*(n)
n
ssize_t n
Definition: bigdecimal.c:5655
d
d
Definition: strlcat.c:58
CHAR_BIT
#define CHAR_BIT
Definition: ruby.h:208
data_at
#define data_at(n)

#define UNALIGNED_ADD | ( |  | n | ) |

Value:
case (n) + 1: \
t |= data_at(n) << CHAR_BIT*(n)
n
ssize_t n
Definition: bigdecimal.c:5655
CHAR_BIT
#define CHAR_BIT
Definition: ruby.h:208
t
int t
Definition: ripper.c:14699
data_at
#define data_at(n)

#define UNALIGNED_ADD_4 UNALIGNED_ADD(2); UNALIGNED_ADD(1); UNALIGNED_ADD(0)

#define UNALIGNED_ADD_ALL UNALIGNED_ADD_4

Referenced by st_hash().

#define UNALIGNED_WORD_ACCESS 0

Definition at line 1251 of file st.c.

## Typedef Documentation

typedef struct st_packed_entry st_packed_entry

typedef struct st_table_entry st_table_entry

Definition at line 18 of file st.c.

## Function Documentation

static void add_direct | ( | st_table * | table,
|  | st_data_t | key,
|  | st_data_t | value,
|  | st_index_t | hash_val,
|  | register st_index_t | bin_pos
| ) |  |
| inline static

Definition at line 483 of file st.c.

References st_table_entry::back, st_table_entry::fore, st_table::head, new_entry(), st_table::num_bins, st_table::num_entries, rehash(), ST_DEFAULT_MAX_DENSITY, and st_table::tail.

Referenced by add_packed_direct(), st_add_direct(), st_insert(), st_insert2(), and st_update().

static void add_packed_direct | ( | st_table * | table,
|  | st_data_t | key,
|  | st_data_t | value,
|  | st_index_t | hash_val
| ) |  |
| static

Definition at line 542 of file st.c.

References add_direct(), i, st_table::num_bins, st_table::num_entries, PHASH_SET, PKEY_SET, PVAL_SET, st_table::real_entries, and unpack_entries().

Referenced by st_add_direct(), st_insert(), st_insert2(), and st_update().

static st_table_entry* find_entry | ( | st_table * | table,
|  | st_data_t | key,
|  | st_index_t | hash_val,
|  | st_index_t | bin_pos
| ) |  |
| static

Definition at line 381 of file st.c.

References st_table::bins, COLLISION, FOUND_ENTRY, st_table_entry::next, ptr, and PTR_NOT_EQUAL.

Referenced by st_get_key(), and st_lookup().

static st_index_t find_packed_index | ( | st_table * | table,
|  | st_index_t | hash_val,
|  | st_data_t | key
| ) |  |
| inline static

Definition at line 396 of file st.c.

References EQUAL, i, PHASH, PKEY, and real_entries.

Referenced by st_delete(), st_delete_safe(), st_foreach_check(), st_get_key(), st_insert(), st_insert2(), st_lookup(), and st_update().

static st_index_t murmur | ( | st_index_t | h,
|  | st_index_t | k,
|  | int | r
| ) |  |
| inline static

Definition at line 1272 of file st.c.

References m, MurmurMagic, and r.

Referenced by murmur_finish().

static st_index_t murmur_finish | ( | st_index_t | h | ) |
| inline static

Definition at line 1291 of file st.c.

References murmur(), and MurmurMagic.

Referenced by st_hash().

static st_table_entry* new_entry | ( | st_table * | table,
|  | st_data_t | key,
|  | st_data_t | value,
|  | st_index_t | hash_val,
|  | register st_index_t | bin_pos
| ) |  |
| inline static

Definition at line 468 of file st.c.

References st_table::bins, st_table_entry::hash, st_table_entry::key, key, st_table_entry::next, st_table_entry::record, st_alloc_entry, and value.

Referenced by add_direct(), and unpack_entries().

static st_index_t new_size | ( | st_index_t | size | ) |
| static

Definition at line 184 of file st.c.

References i, MINSIZE, numberof, rb_eRuntimeError, and rb_raise().

Referenced by onigenc_property_list_add_property(), rehash(), resize_property_list(), and st_init_table_with_size().

static void rehash | ( | st_table * |  | ) |
| static

Referenced by add_direct().

static void rehash | ( | register st_table * | table | ) |
| static

Definition at line 638 of file st.c.

References st_table::bins, st_table_entry::fore, st_table_entry::hash, st_table::head, new_size(), st_table_entry::next, st_table::num_bins, ptr, and st_realloc_bins().

static void remove_entry | ( | st_table * | table,
|  | st_table_entry * | ptr
| ) |  |
| inline static

Definition at line 707 of file st.c.

References st_table_entry::back, st_table_entry::fore, st_table::head, st_table::num_entries, and st_table::tail.

Referenced by st_delete(), st_delete_safe(), st_foreach(), st_foreach_check(), and st_update().

static void remove_packed_entry | ( | st_table * | table,
|  | st_index_t | i
| ) |  |
| inline static

Definition at line 123 of file st.c.

References MEMMOVE, st_table::num_entries, PACKED_ENT, st_table::real_entries, and real_entries.

Referenced by st_delete(), st_foreach(), and st_update().

static void remove_safe_packed_entry | ( | st_table * | table,
|  | st_index_t | i,
|  | st_data_t | never
| ) |  |
| inline static

Definition at line 134 of file st.c.

References st_table::num_entries, PHASH_SET, PKEY_SET, and PVAL_SET.

Referenced by st_delete_safe(), and st_foreach_check().

void st_add_direct | ( | st_table * | table,
|  | st_data_t | key,
|  | st_data_t | value
| ) |  |

Definition at line 624 of file st.c.

References add_direct(), add_packed_direct(), do_hash, st_table::entries_packed, and st_table::num_bins.

Referenced by boot_defclass(), define_final0(), generic_ivar_set(), make_transcoder_entry(), method_entry_i(), move_refined_method(), rb_alias_variable(), rb_autoload(), rb_copy_generic_ivar(), rb_define_class(), rb_define_module(), rb_global_entry(), rb_ivar_set(), register_symid_str(), set_syserr(), transcode_search_path(), transcode_search_path_i(), w_object(), and w_symbol().

void st_cleanup_safe | ( | st_table * | table,
|  | st_data_t | never
| ) |  |

Definition at line 797 of file st.c.

References st_table::bins, st_table::entries_packed, i, st_table_entry::key, last, st_table_entry::next, st_table::num_bins, st_table::num_entries, PACKED_ENT, PKEY, ptr, st_table::real_entries, st_free_entry, and tmp.

Referenced by hash_foreach_ensure().

void st_clear | ( | st_table * | table | ) |

Definition at line 308 of file st.c.

References st_table::bins, st_table::entries_packed, st_table::head, i, st_table_entry::next, st_table::num_bins, st_table::num_entries, ptr, st_table::real_entries, st_free_entry, and st_table::tail.

Referenced by rb_hash_clear(), rb_thread_atfork_internal(), and st_free_table().

st_table* st_copy | ( | st_table * | old_table | ) |

Definition at line 658 of file st.c.

References st_table_entry::back, st_table::bins, st_table::entries_packed, st_table_entry::fore, st_table_entry::hash, st_table::head, MEMCPY, st_table_entry::next, st_table::num_bins, ptr, st_alloc_bins, st_alloc_entry, st_alloc_table, st_dealloc_table, st_free_table(), and st_table::tail.

Referenced by init_copy(), rb_copy_generic_ivar(), rb_hash_dup(), rb_hash_initialize_copy(), rb_hash_s_create(), rb_hash_to_h(), rb_mod_init_copy(), and rb_singleton_class_clone_and_attach().

int st_delete | ( | register st_table * | table,
|  | register st_data_t * | key,
|  | st_data_t * | value
| ) |  |

Definition at line 724 of file st.c.

References st_table::bins, do_hash, st_table::entries_packed, EQUAL, find_packed_index(), i, st_table_entry::key, st_table_entry::next, st_table::num_bins, PKEY, ptr, PVAL, real_entries, st_table_entry::record, remove_entry(), remove_packed_entry(), and st_free_entry.

int st_delete_safe | ( | register st_table * | table,
|  | register st_data_t * | key,
|  | st_data_t * | value,
|  | st_data_t | never
| ) |  |

Definition at line 761 of file st.c.

References st_table::bins, do_hash, st_table::entries_packed, EQUAL, find_packed_index(), i, st_table_entry::key, st_table_entry::next, st_table::num_bins, PKEY, ptr, PVAL, real_entries, st_table_entry::record, remove_entry(), and remove_safe_packed_entry().

int st_foreach | ( | st_table * | table,
|  | int(*)(ANYARGS) | func,
|  | st_data_t | arg
| ) |  |

Definition at line 1000 of file st.c.

References arg, st_table::bins, st_table::entries_packed, FIND_ENTRY, st_table_entry::fore, st_table_entry::hash, hash, st_table::head, i, st_table_entry::key, key, last, st_table_entry::next, st_table::num_bins, PHASH, PKEY, ptr, PVAL, st_table::real_entries, st_table_entry::record, remove_entry(), remove_packed_entry(), retval, ST_CHECK, ST_CONTINUE, ST_DELETE, st_free_entry, ST_STOP, tmp, and val.

Referenced by class_instance_method_list(), clear_coverage(), count_nodes(), count_objects(), count_objects_size(), count_tdata_objects(), enc_names(), exit_handler(), extract_keywords(), fc_i(), get_loaded_features_index(), include_modules_at(), mark_const_tbl(), mark_hash(), mark_m_tbl(), mark_marshal_compat_t(), mark_set(), mark_tbl(), proc_waitall(), rb_ary_uniq(), rb_ary_uniq_bang(), rb_check_deadlock(), rb_check_exec_env(), rb_check_exec_options(), rb_clear_trace_func(), rb_coverage_result(), rb_econv_asciicompat_encoding(), rb_enc_aliases(), rb_enc_name_list(), rb_execarg_extract_options(), rb_execarg_fixup(), rb_feature_p(), rb_free_const_table(), rb_free_m_table(), rb_mod_init_copy(), rb_obj_singleton_methods(), rb_objspace_call_finalizer(), rb_prepend_module(), rb_singleton_class_clone_and_attach(), rb_sym_all_symbols(), rb_thread_atfork_internal(), rb_thread_fd_close(), rb_thread_keys(), rb_thread_list(), rb_thread_terminate_all(), rb_vm_check_redefinition_by_prepend(), rb_vm_mark(), rb_waitpid(), reachable_objects_from(), thgroup_list(), transcode_search_path(), validate_labels(), wmap_free(), wmap_mark(), and wmap_memsize().

int st_foreach_check | ( | st_table * | table,
|  | int(*)(ANYARGS) | func,
|  | st_data_t | arg,
|  | st_data_t | never
| ) |  |

Definition at line 909 of file st.c.

References arg, st_table::bins, st_table::entries_packed, FIND_ENTRY, find_packed_index(), st_table_entry::fore, st_table_entry::hash, hash, st_table::head, i, st_table_entry::key, key, last, st_table_entry::next, st_table::num_bins, PHASH, PKEY, ptr, PVAL, st_table::real_entries, st_table_entry::record, remove_entry(), remove_safe_packed_entry(), retval, ST_CHECK, ST_CONTINUE, ST_DELETE, ST_STOP, tmp, and val.

Referenced by hash_foreach_call(), and st_foreach_safe().

void st_free_table | ( | st_table * | table | ) |

Definition at line 334 of file st.c.

References st_table::bins, st_table::num_bins, st_clear(), st_dealloc_table, and st_free_bins.

Referenced by ary_recycle_hash(), autoload_free(), class_instance_method_list(), clear_dump_arg(), clear_load_arg(), cvar_list(), exit_handler(), fiber_free(), flatten(), free_enc2cp(), generic_ivar_remove(), init_copy(), Init_win32ole(), iseq_build_from_ary_body(), iseq_data_to_ary(), obj_free(), rb_const_list(), rb_copy_generic_ivar(), rb_free_const_table(), rb_free_generic_ivar(), rb_free_m_table(), rb_hash_rehash(), rb_mod_init_copy(), rb_obj_singleton_methods(), rb_objspace_call_finalizer(), ruby_vm_destruct(), st_copy(), thread_free(), transcode_search_path(), and wmap_free().

int st_get_key | ( | st_table * | table,
|  | register st_data_t | key,
|  | st_data_t * | result
| ) |  |

Definition at line 437 of file st.c.

References do_hash, st_table::entries_packed, find_entry(), find_packed_index(), i, st_table_entry::key, st_table::num_bins, PKEY, ptr, and real_entries.

st_index_t st_hash | ( | const void * | ptr,
|  | size_t | len,
|  | st_index_t | h
| ) |  |

Definition at line 1313 of file st.c.

References CHAR_BIT, d, data, int, murmur_finish(), murmur_step, MurmurMagic, ptr, SIZEOF_ST_INDEX_T, t, and UNALIGNED_ADD_ALL.

Referenced by hash_i(), and strhash().

st_index_t st_hash_end | ( | st_index_t | h | ) |

Definition at line 1477 of file st.c.

References murmur_step.

st_index_t st_hash_start | ( | st_index_t | h | ) |

Definition at line 1486 of file st.c.

st_index_t st_hash_uint | ( | st_index_t | h,
|  | st_index_t | i
| ) |  |

Definition at line 1446 of file st.c.

References i, murmur1, and v.

st_index_t st_hash_uint32 | ( | st_index_t | h,
|  | uint32_t | i
| ) |  |

Definition at line 1440 of file st.c.

References murmur_step.

st_table* st_init_numtable | ( | void |  | ) |

Definition at line 272 of file st.c.

References st_init_table(), and type_numhash.

Referenced by class_instance_method_list(), constat_handle(), fiber_init(), find_class_path(), flatten(), generic_ivar_set(), init_constants(), init_enc2cp(), Init_Exception(), init_heap(), Init_marshal(), Init_var_tables(), Init_VM(), Init_win32ole(), insn_make_insn_table(), iseq_compile_each(), iseq_data_to_ary(), iseq_load(), marshal_dump(), marshal_load(), mod_cvar_at(), rb_autoload(), rb_class_boot(), rb_const_set(), rb_cvar_set(), rb_include_class_new(), rb_iseq_build_from_ary(), rb_ivar_set(), rb_mod_const_at(), rb_mod_init_copy(), rb_module_new(), rb_obj_freeze(), rb_obj_singleton_methods(), rb_prepend_module(), rb_singleton_class_attached(), rb_singleton_class_clone_and_attach(), rb_thread_local_aset(), rb_waitpid(), reachable_objects_from(), socklist_insert(), vm_init_redefined_flag(), and wmap_allocate().

st_table* st_init_numtable_with_size | ( | st_index_t | size | ) |

Definition at line 278 of file st.c.

References st_init_table_with_size(), and type_numhash.

Referenced by Init_sym().

st_table* st_init_strcasetable | ( | void |  | ) |

Definition at line 296 of file st.c.

References st_init_table().

Referenced by Init_transcode(), make_transcoder_entry(), rb_enc_init(), transcode_search_path(), and w_encoding().

st_table* st_init_strcasetable_with_size | ( | st_index_t | size | ) |

Definition at line 302 of file st.c.

References st_init_table_with_size().

st_table* st_init_strtable | ( | void |  | ) |

Definition at line 284 of file st.c.

References st_init_table().

Referenced by Init_load(), load_lock(), ruby_init_ext(), and zone_str().

st_table* st_init_strtable_with_size | ( | st_index_t | size | ) |

Definition at line 290 of file st.c.

References st_init_table_with_size().

st_table* st_init_table | ( | const struct st_hash_type * | type | ) |

Definition at line 266 of file st.c.

References st_init_table_with_size().

Referenced by rb_hash_tbl(), st_init_numtable(), st_init_strcasetable(), and st_init_strtable().

st_table* st_init_table_with_size | ( | const struct st_hash_type * | type,
|  | st_index_t | size
| ) |  |

Definition at line 229 of file st.c.

References st_table::bins, e, st_table::entries_packed, getenv(), st_table::head, MAX_PACKED_HASH, new_size(), st_table::num_bins, st_table::num_entries, size, st_alloc_bins, st_alloc_table, ST_DEFAULT_PACKED_TABLE_SIZE, st_table::tail, tbl, st_table::type, and type.

Referenced by Init_sym(), rb_hash_rehash(), st_init_numtable_with_size(), st_init_strcasetable_with_size(), st_init_strtable_with_size(), and st_init_table().

int st_insert | ( | register st_table * | table,
|  | register st_data_t | key,
|  | st_data_t | value
| ) |  |

Definition at line 559 of file st.c.

References add_direct(), add_packed_direct(), do_hash, st_table::entries_packed, FIND_ENTRY, find_packed_index(), i, ptr, PVAL_SET, real_entries, st_table_entry::record, and value.

int st_insert2 | ( | register st_table * | table,
|  | register st_data_t | key,
|  | st_data_t | value,
|  | st_data_t(*)(st_data_t) | func
| ) |  |

Definition at line 590 of file st.c.

References add_direct(), add_packed_direct(), do_hash, st_table::entries_packed, FIND_ENTRY, find_packed_index(), i, key, ptr, PVAL_SET, real_entries, st_table_entry::record, and value.

int st_lookup | ( | st_table * | table,
|  | register st_data_t | key,
|  | st_data_t * | value
| ) |  |

Definition at line 409 of file st.c.

References do_hash, st_table::entries_packed, find_entry(), find_packed_index(), i, st_table::num_bins, ptr, PVAL, real_entries, and st_table_entry::record.

size_t st_memsize | ( | const st_table * | table | ) |

Definition at line 342 of file st.c.

References st_table::entries_packed, st_table::num_bins, and st_table::num_entries.

Referenced by autoload_memsize(), fiber_memsize(), memsize_of(), rb_generic_ivar_memsize(), thread_memsize(), vm_memsize(), and wmap_memsize().

int st_numcmp | ( | st_data_t | x,
|  | st_data_t | y
| ) |  |

Definition at line 1569 of file st.c.

Referenced by STATIC_ASSERT().

st_index_t st_numhash | ( | st_data_t | n | ) |

Definition at line 1575 of file st.c.

References n.

Referenced by STATIC_ASSERT().

static st_table_entry** st_realloc_bins | ( | st_table_entry ** | bins,
|  | st_index_t | newsize,
|  | st_index_t | oldsize
| ) |  |
| inline static

Definition at line 98 of file st.c.

References bins, MEMZERO, and realloc.

Referenced by rehash(), and unpack_entries().

int st_strcasecmp | ( | const char * | s1,
|  | const char * | s2
| ) |  |

Definition at line 1500 of file st.c.

int st_strncasecmp | ( | const char * | s1,
|  | const char * | s2,
|  | size_t | n
| ) |  |

Definition at line 1524 of file st.c.

int st_update | ( | st_table * | table,
|  | st_data_t | key,
|  | st_update_callback_func * | func,
|  | st_data_t | arg
| ) |  |

Definition at line 834 of file st.c.

References add_direct(), add_packed_direct(), arg, st_table::bins, do_hash, st_table::entries_packed, FIND_ENTRY, find_packed_index(), st_table_entry::fore, i, st_table_entry::key, key, last, st_table_entry::next, st_table::num_bins, PKEY, ptr, PVAL, PVAL_SET, real_entries, st_table_entry::record, remove_entry(), remove_packed_entry(), retval, ST_CONTINUE, ST_DELETE, st_free_entry, tmp, and value.

Referenced by kwmerge_i(), load_unlock(), ruby_init_ext(), wmap_finalize(), and zone_str().

STATIC_ASSERT | ( | st_packed_entry | ,
|  | sizeof(st_packed_entry) | = `= sizeof(st_table_entry*[PACKED_UNIT])`
| ) |  |

Definition at line 42 of file st.c.

References st_numcmp(), and st_numhash().

static st_index_t strcasehash | ( | st_data_t | arg | ) |
| static

Definition at line 1549 of file st.c.

References c, FNV1_32A_INIT, FNV_32_PRIME, and hval.

static st_index_t strhash | ( | st_data_t | arg | ) |
| static

Definition at line 1492 of file st.c.

References FNV1_32A_INIT, st_hash(), and strlen().

static void unpack_entries | ( | register st_table * | table | ) |
| static

Definition at line 507 of file st.c.

References st_table::as, st_table_entry::back, st_table::bins, st_table::entries_packed, st_table_entry::fore, st_packed_entry::hash, hash, st_table::head, i, st_packed_entry::key, key, MAX_PACKED_HASH, MEMCPY, MEMZERO, new_entry(), NULL, st_table::num_bins, st_table::packed, PACKED_BINS, ST_DEFAULT_INIT_TABLE_SIZE, st_realloc_bins(), table, st_table::tail, st_packed_entry::val, and val.

Referenced by add_packed_direct().

## Variable Documentation

const unsigned int primes[]
| static

Definition at line 151 of file st.c.

struct st_hash_type type_strcasehash
| static

Initial value:
= {
st_strcasecmp,
strcasehash,
}
st_strcasecmp
int st_strcasecmp(const char *s1, const char *s2)
Definition: st.c:1500
strcasehash
static st_index_t strcasehash(st_data_t)
Definition: st.c:1549

Definition at line 69 of file st.c.

struct st_hash_type type_strhash
| static

Initial value:
= {
strcmp,
strhash,
}
strhash
static st_index_t strhash(st_data_t)
Definition: st.c:1492

Definition at line 63 of file st.c.