squat-trie.c revision 4fbd8de028e97cb14496fbcf74f3b878831274ae
402f9183489c1a75736b1e9068c33fe2741a366dTimo Sirainen/* Copyright (C) 2006 Timo Sirainen */
402f9183489c1a75736b1e9068c33fe2741a366dTimo Sirainen/* 8bit character counter holds only 255, so we can't use 256. */
402f9183489c1a75736b1e9068c33fe2741a366dTimo Sirainen/* for non-x86 use memcpy() when accessing unaligned int* addresses */
402f9183489c1a75736b1e9068c33fe2741a366dTimo Sirainen (((size) + sizeof(void *)-1) & ~((unsigned int) sizeof(void *)-1))
402f9183489c1a75736b1e9068c33fe2741a366dTimo Sirainen void *mmap_base; /* NULL with mmap_disable=yes */
struct squat_trie_build_context {
unsigned int prev_added_size;
unsigned int node_count;
unsigned int deleted_space;
struct squat_trie_compress_context {
const char *tmp_path;
int fd;
unsigned int node_count;
struct trie_node {
(struct trie_node **) \
(struct trie_node **) \
uint8_t c;
c = num;
const uint8_t *c = *p;
unsigned int bits = 0;
if (c == end) {
return value;
static const uint16_t *
size_t i;
for (i = 0; i < size; i++) {
chr = 0;
chr = 0;
#ifndef ALLOW_UNALIGNED_ACCESS
for (i = 0; i < count; i++)
#ifndef ALLOW_UNALIGNED_ACCESS
for (i = 0; i < count; i++) {
sizeof(children[i]));
#ifndef ALLOW_UNALIGNED_ACCESS
for (i = 0; i < count; i++) {
#ifndef ALLOW_UNALIGNED_ACCESS
for (i = 0; i < count; i++) {
sizeof(idx));
if (ret < 0) {
if (j >= 0 && i == chars[j])
chars[i] = i;
chars16_count = 0;
chars16_memsize = 0;
chars16_offset = 0;
const void *end_offset;
if (chars16_count == 0)
sizeof(uint16_t));
unsigned int count)
for (i = 0; i < count; i++) {
int ret;
if (ret < 0) {
if (ret == 0) {
if (ret <= 0)
if (ret < 0) {
int fd;
struct squat_trie *
return trie;
int ret;
return ret;
if (ret == 0) {
*uid_r = 0;
return ret;
int ret;
if (ret == 0)
return ret;
int ret;
if (ret == 0) {
if (ret <= 0)
return ret;
if (ret == 0)
if (ret < 0)
if (created) {
static struct trie_node *
idx_size);
for (i = 0; i < MAX_8BIT_CHAR_COUNT; i++)
chars[i] = i;
if (chars16_count > 0) {
return node;
static struct trie_node *
unsigned int level)
return node;
int ret;
unsigned int count;
sizeof(chars[0]),
&char_idx);
if (!match) {
unsigned int count;
char_idx = 0;
unsigned int idx_size;
sizeof(chars[0]),
&char_idx);
if (!match) {
if (ret < 0)
if (ret > 0)
uid) < 0)
static uint32_t
for (i = 0; i < BLOCK_SIZE; i++) {
if (data[i] == 0)
return FALSE;
return TRUE;
struct squat_trie_build_context *
*last_uid_r = 0;
return ctx;
if (ret == 0)
return ret;
unsigned int i, tmp_size;
t_push();
t_pop();
t_pop();
t_pop();
t_pop();
t_pop();
unsigned int count)
for (i = 0; i < count; i++) {
unsigned int count)
for (i = 0; i < count; i++) {
offset++;
unsigned int current_message_count)
return TRUE;
unsigned int i, j, old_count;
for (i = j = 0; i < old_count; i++) {
for (i = j = 0; i < old_count; i++) {
unsigned int i, j, old_count;
for (i = j = 0; i < old_count; i++) {
for (i = j = 0; i < old_count; i++) {
unsigned int i, j, old_count;
for (i = j = 0; i < old_count; i++) {
if (child_src[i] != 0)
for (i = j = 0; i < old_count; i++) {
if (child_src[i] != 0)
unsigned int i, j, old_count;
for (i = j = 0; i < old_count; i++) {
if (child_src[i] != 0)
for (i = j = 0; i < old_count; i++) {
if (child_src[i] != 0)
unsigned int level)
int ret = 0;
for (i = 0; i < count; i++) {
if (ret < 0)
int ret;
if (ret < 0)
if (ret == 0) {
idx8[i] = 0;
if (compress_chars) {
if (ret < 0)
if (ret == 0) {
idx16[i] = 0;
if (compress_chars) {
int ret;
if (ret == 0)
if (ret == 0)
unsigned int orig_lock_count;
int ret;
if (ret == 0) {
&file_lock) <= 0)
if (ret == 0) {
if (ret < 0) {
return ret;
unsigned int current_message_count)
bool compress;
int ret;
return ret;
if (compress)
return ret;
if (list == 0)
len--;
if (list == 0) {
const char *str)
unsigned int len;
int ret;
return ret;
if (list == 0) {
const char *str)
unsigned int len;
int ret;
return ret;