Full Code of vipshop/vire for AI

master fdb7db80f875 cached
174 files
1.6 MB
462.4k tokens
1779 symbols
1 requests
Download .txt
Showing preview only (1,719K chars total). Download the full file or copy to clipboard to get everything.
Repository: vipshop/vire
Branch: master
Commit: fdb7db80f875
Files: 174
Total size: 1.6 MB

Directory structure:
gitextract_y_mdrj8b/

├── .gitignore
├── ChangeLog
├── LICENSE
├── Makefile.am
├── NOTICE
├── README.md
├── conf/
│   └── vire.conf
├── configure.ac
├── dep/
│   ├── .gitignore
│   ├── Makefile.am
│   ├── ae/
│   │   ├── Makefile.am
│   │   ├── ae.c
│   │   ├── ae.h
│   │   ├── ae_epoll.c
│   │   ├── ae_evport.c
│   │   ├── ae_kqueue.c
│   │   └── ae_select.c
│   ├── darray/
│   │   ├── Makefile.am
│   │   ├── darray.c
│   │   └── darray.h
│   ├── dhashkit/
│   │   ├── Makefile.am
│   │   ├── dcrc16.c
│   │   ├── dcrc32.c
│   │   ├── dfnv.c
│   │   ├── dhashkit.h
│   │   ├── dhsieh.c
│   │   ├── djenkins.c
│   │   ├── dketama.c
│   │   ├── dmd5.c
│   │   ├── dmodula.c
│   │   ├── dmurmur.c
│   │   ├── done_at_a_time.c
│   │   ├── drandom.c
│   │   └── dsha1.c
│   ├── dlist/
│   │   ├── Makefile.am
│   │   ├── dlist.c
│   │   ├── dlist.h
│   │   ├── dlockqueue.c
│   │   ├── dlockqueue.h
│   │   ├── dmtqueue.c
│   │   └── dmtqueue.h
│   ├── dmalloc/
│   │   ├── Makefile.am
│   │   ├── dmalloc.c
│   │   └── dmalloc.h
│   ├── himemcached-0.1.0/
│   │   ├── Makefile.am
│   │   ├── himcdep/
│   │   │   ├── sds.c
│   │   │   └── sds.h
│   │   ├── himcread.c
│   │   ├── himcread.h
│   │   ├── himemcached.c
│   │   └── himemcached.h
│   ├── hiredis-0.13.3/
│   │   └── .gitignore
│   ├── jemalloc-4.2.0/
│   │   └── .gitignore
│   ├── jemalloc-4.2.0.tar.bz2
│   ├── sds/
│   │   ├── Makefile.am
│   │   ├── sds.c
│   │   ├── sds.h
│   │   └── sdsalloc.h
│   └── util/
│       ├── Makefile.am
│       ├── dlog.c
│       ├── dlog.h
│       ├── dspecialconfig.h
│       ├── dutil.c
│       └── dutil.h
├── m4/
│   └── .gitignore
├── notes/
│   ├── c-styleguide.txt
│   ├── debug.txt
│   └── socket.txt
├── scripts/
│   └── .gitignore
├── src/
│   ├── Makefile.am
│   ├── vr.c
│   ├── vr_aof.c
│   ├── vr_aof.h
│   ├── vr_backend.c
│   ├── vr_backend.h
│   ├── vr_bitops.c
│   ├── vr_bitops.h
│   ├── vr_block.c
│   ├── vr_block.h
│   ├── vr_client.c
│   ├── vr_client.h
│   ├── vr_command.c
│   ├── vr_command.h
│   ├── vr_conf.c
│   ├── vr_conf.h
│   ├── vr_connection.c
│   ├── vr_connection.h
│   ├── vr_core.c
│   ├── vr_core.h
│   ├── vr_db.c
│   ├── vr_db.h
│   ├── vr_dict.c
│   ├── vr_dict.h
│   ├── vr_eventloop.c
│   ├── vr_eventloop.h
│   ├── vr_hyperloglog.c
│   ├── vr_hyperloglog.h
│   ├── vr_intset.c
│   ├── vr_intset.h
│   ├── vr_listen.c
│   ├── vr_listen.h
│   ├── vr_lzf.h
│   ├── vr_lzfP.h
│   ├── vr_lzf_c.c
│   ├── vr_lzf_d.c
│   ├── vr_master.c
│   ├── vr_master.h
│   ├── vr_multi.c
│   ├── vr_multi.h
│   ├── vr_notify.c
│   ├── vr_notify.h
│   ├── vr_object.c
│   ├── vr_object.h
│   ├── vr_pubsub.c
│   ├── vr_pubsub.h
│   ├── vr_quicklist.c
│   ├── vr_quicklist.h
│   ├── vr_rbtree.c
│   ├── vr_rbtree.h
│   ├── vr_rdb.c
│   ├── vr_rdb.h
│   ├── vr_replication.c
│   ├── vr_replication.h
│   ├── vr_scripting.c
│   ├── vr_scripting.h
│   ├── vr_server.c
│   ├── vr_server.h
│   ├── vr_signal.c
│   ├── vr_signal.h
│   ├── vr_slowlog.c
│   ├── vr_slowlog.h
│   ├── vr_stats.c
│   ├── vr_stats.h
│   ├── vr_t_hash.c
│   ├── vr_t_hash.h
│   ├── vr_t_list.c
│   ├── vr_t_list.h
│   ├── vr_t_set.c
│   ├── vr_t_set.h
│   ├── vr_t_string.c
│   ├── vr_t_string.h
│   ├── vr_t_zset.c
│   ├── vr_t_zset.h
│   ├── vr_thread.c
│   ├── vr_thread.h
│   ├── vr_util.c
│   ├── vr_util.h
│   ├── vr_worker.c
│   ├── vr_worker.h
│   ├── vr_ziplist.c
│   ├── vr_ziplist.h
│   ├── vr_zipmap.c
│   └── vr_zipmap.h
├── tests/
│   ├── .gitignore
│   ├── Makefile.am
│   ├── vrabtest.c
│   ├── vrabtest.h
│   ├── vrt_backend.c
│   ├── vrt_backend.h
│   ├── vrt_benchmark.c
│   ├── vrt_check_data.c
│   ├── vrt_check_data.h
│   ├── vrt_dispatch_data.c
│   ├── vrt_dispatch_data.h
│   ├── vrt_produce_data.c
│   ├── vrt_produce_data.h
│   ├── vrt_public.c
│   ├── vrt_public.h
│   ├── vrt_simple.c
│   ├── vrt_simple.h
│   ├── vrt_util.c
│   ├── vrt_util.h
│   └── vrtest.c
└── tools/
    └── .gitignore

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# pyc
*.pyc

# Compiled Object files
*.lo
*.o

# Compiled Dynamic libraries
*.so

# Compiled Static libraries
*.la
*.a

# Compiled misc
*.dep
*.gcda
*.gcno
*.gcov

# Packages
*.tar.gz
*.tar.bz2

# Logs
*.log

# vire
*.swp
*.~
*.project
*.cproject

# Core and executable
core*
vire

# extracted jemalloc
!/dep/jemalloc-*

# Autotools
.deps
.libs

/aclocal.m4
/autom4te.cache
/stamp-h1
/autoscan.log
/libtool

/config/config.guess
/config/config.sub
/config/depcomp
/config/install-sh
/config/ltmain.sh
/config/missing
/config

/config.h
/config.h.in
/config.h.in~
/config.log
/config.status
/configure.scan
/configure

Makefile
Makefile.in


================================================
FILE: ChangeLog
================================================
 2016-10-25  deep011  <diguo58@gmail.com>
    * vire: version 1.0.0 release
      vire (pronounced "vip-redis") is a multithread redis(based on redis-3.2.0) maintains in vipshop.
      multi-threads support.
      command type CONNECTION supported: ping,quit,echo,select,auth,admin.
      command type SERVER supported: info,flushall,flushdb,time,dbsize,command,config,client,slowlog.
      command type KEY supported: del,exists,ttl,pttl,expire,expireat,pexpire,pexpireat,persist,randomkey,type,keys,scan,object.
      command type STRING supported: get,set,setnx,setex,psetex,incr,decr,incrby,decrby,append,strlen,getset,incrbyfloat,setbit,getbit,setrange,getrange,bitcount,bitpos,mget,mset.
      command type HASH supported: hset,hget,hlen,hdel,hexists,hkeys,hvals,hgetall,hincrby,hincrbyfloat,hmget,hmset,hsetnx,hstrlen,hscan.
      command type LIST supported: rpush,lpush,lrange,rpop,lpop,llen,lrem,ltrim,lindex,lset.
      command type SET supported: sadd,smembers,scard,srem,spop,sismember,sscan,sunion,sunionstore,sdiff,sdiffstore,sinter,sinterstore.
      command type SORTEDSET supported: zadd,zincrby,zrange,zrevrange,zrem,zcard,zcount,zrangebyscore,zrevrangebyscore,zrank,zrevrank,zscore,zremrangebyscore,zremrangebyrank,zremrangebylex,zscan.
      command type HYPERLOGLOG supported: pfadd,pfcount.
      config option added(used for config file and 'config get/set' command): port,databases,internal-dbs-per-databases,requirepass,adminpass,commands-need-adminpass,maxclients,maxmemory,maxmemory-policy,maxmemory-samples,max-time-complexity-limit,slowlog-log-slower-than,slowlog-max-len.
      viretest added that is for unit test.
      vireabtest added that is for compare command execution and data consistency with redis-3.2.0.
      vire-benchmark added that is modified from redis-benchmark but multi-threads supported and pressure test vire.

================================================
FILE: LICENSE
================================================

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

================================================
FILE: Makefile.am
================================================
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.h.in config.h.in~ stamp-h.in

ACLOCAL_AMFLAGS = -I m4

SUBDIRS = dep src tests

EXTRA_DIST = README.md NOTICE LICENSE ChangeLog conf scripts notes


================================================
FILE: NOTICE
================================================


================================================
FILE: README.md
================================================
# vire

**vire** (pronounced "vip-redis") is a multithread redis(based on redis-3.2.0) maintains in vipshop.

### QQ交流群:276406429

## Dependence

Please install automake, libtool, autoconf and bzip2 at first.

## Build

To build vire from source with _debug logs enabled_ and _assertions enabled_:

    $ git clone  https://github.com/vipshop/vire.git
    $ cd vire
    $ autoreconf -fvi
    $ ./configure --enable-debug=full
    $ make
    $ src/vire -h

A quick checklist:

+ Use newer version of gcc (older version of gcc has problems)
+ Use CFLAGS="-O1" ./configure && make
+ Use CFLAGS="-O3 -fno-strict-aliasing" ./configure && make
+ `autoreconf -fvi && ./configure` needs `automake` and `libtool` to be installed

## Run

    $ src/vire -c conf/vire.conf -o log -T 6 -d

## Features

+ Multithread.
+ Fast.
+ Works with Linux, *BSD, OS X and SmartOS (Solaris)

## Help

    Usage: vire [-?hVdt] [-v verbosity level] [-o output file]
                [-c conf file] [-p pid file]
                [-T worker threads number]
    
    Options:
    -h, --help             : this help
    -V, --version          : show version and exit
    -t, --test-conf        : test configuration for syntax errors and exit
    -d, --daemonize        : run as a daemon
    -v, --verbose=N        : set logging level (default: 5, min: 0, max: 11)
    -o, --output=S         : set logging file (default: stderr)
    -c, --conf-file=S      : set configuration file (default: conf/vire.conf)
    -p, --pid-file=S       : set pid file (default: off)
    -T, --thread_num=N     : set the worker threads number (default: 6)

## Support redis command so far

#### Connection

+ ping
+ quit
+ echo
+ select
+ auth
+ admin

#### Server

+ info
+ flushall
+ flushdb
+ time
+ dbsize
+ command
+ config
+ client
+ slowlog

#### Key

+ del
+ exists
+ ttl
+ pttl
+ expire
+ expireat
+ pexpire
+ pexpireat
+ persist
+ randomkey
+ type
+ keys
+ scan
+ object

#### String

+ get
+ set
+ setnx
+ setex
+ psetex
+ incr
+ decr
+ incrby
+ decrby
+ append
+ strlen
+ getset
+ incrbyfloat
+ setbit
+ getbit
+ setrange
+ getrange
+ bitcount
+ bitpos
+ mget
+ mset

#### Hash

+ hset
+ hget
+ hlen
+ hdel
+ hexists
+ hkeys
+ hvals
+ hgetall
+ hincrby
+ hincrbyfloat
+ hmget
+ hmset
+ hsetnx
+ hstrlen
+ hscan

#### List

+ rpush
+ lpush
+ lrange
+ rpop
+ lpop
+ llen
+ lrem
+ ltrim
+ lindex
+ lset

#### Set

+ sadd
+ smembers
+ scard
+ srem
+ spop
+ sismember
+ sscan
+ sunion
+ sunionstore
+ sdiff
+ sdiffstore
+ sinter
+ sinterstore

#### SortedSet

+ zadd
+ zincrby
+ zrange
+ zrevrange
+ zrem
+ zcard
+ zcount
+ zrangebyscore
+ zrevrangebyscore
+ zrank
+ zrevrank
+ zscore
+ zremrangebyscore
+ zremrangebyrank
+ zremrangebylex
+ zscan

#### HyperLogLog

+ pfadd
+ pfcount

## License

Copyright © 2016 VIPSHOP Inc.

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0


================================================
FILE: conf/vire.conf
================================================
################################## NETWORK #####################################

# By default, if no "bind" configuration directive is specified, Vire listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Vire is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Vire to listen only into
# the IPv4 lookback interface address (this means Vire will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# bind 127.0.0.1

# Accept connections on the specified port, default is 55555.
# If port 0 is specified Vire will not listen on a TCP socket.
port 55555

################################# GENERAL #####################################

# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
databases 6

# Set the number of internal dbs for every databases. This is used for
# multi-threads avoid too much locker competition.
internal-dbs-per-databases 6

################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared

# Require clients to issue ADMIN <PASSWORD> before processing any other
# needed admin right commands. This might be useful to prevent users from 
# doing some dangerous actions to the host running Vire.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# adminpass iamadmin

# Make some commands need adminpass to execute. Those commands just allowed 
# administrator to execute. This might be useful to prevent users from 
# doing some dangerous actions to the host running Vire.
#
# commands-need-adminpass flushall flushdb keys config

################################### CLIENTS ####################################

# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able to configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# maxclients 10000

############################## MEMORY MANAGEMENT ################################

# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Vire will try to remove keys
# according to the eviction policy selected (see maxmemory-policy).
#
# If Vire can't remove keys according to the policy, or if the policy is
# set to 'noeviction', Vire will start to reply with errors to commands
# that would use more memory, like SET, LPUSH, and so on, and will continue
# to reply to read-only commands like GET.
#
# This option is usually useful when using Vire as an LRU cache, or to set
# a hard memory limit for an instance (using the 'noeviction' policy).
#
# WARNING: If you have slaves attached to an instance with maxmemory on,
# the size of the output buffers needed to feed the slaves are subtracted
# from the used memory count, so that network problems / resyncs will
# not trigger a loop where keys are evicted, and in turn the output
# buffer of slaves is full with DELs of keys evicted triggering the deletion
# of more keys, and so forth until the database is completely emptied.
#
# In short... if you have slaves attached it is suggested that you set a lower
# limit for maxmemory so that there is some free RAM on the system for slave
# output buffers (but this is not needed if the policy is 'noeviction').
#
# maxmemory <bytes>

# MAXMEMORY POLICY: how Vire will select what to remove when maxmemory
# is reached. You can select among five behaviors:
#
# volatile-lru -> remove the key with an expire set using an LRU algorithm, not support now
# allkeys-lru -> remove any key according to the LRU algorithm, not support now
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
#
# Note: with any of the above policies, Vire will return an error on write
#       operations, when there are no suitable keys for eviction.
#
#       At the date of writing these commands are: set setnx setex append
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#       getset mset msetnx exec sort
#
# The default is:
#
# maxmemory-policy noeviction

# LRU and minimal TTL algorithms are not precise algorithms but approximated
# algorithms (in order to save memory), so you can tune it for speed or
# accuracy. For default Vire will check five keys and pick the one that was
# used less recently, you can change the sample size using the following
# configuration directive.
#
# The default of 5 produces good enough results. 10 Approximates very closely
# true LRU but costs a bit more CPU. 3 is very fast but not very accurate.
#
# maxmemory-samples 5

# Max time complexity limit for the commands that their time complexity is O(n).
#
# If n is bigger than max-time-complexity-limit, an error is returned for the client.
# The default of 0 means unlimited.
#
#       At the date of affected commands are: keys
# 
# max-time-complexity-limit 0

################################## SLOW LOG ###################################

# The Vire Slow Log is a system to log queries that exceeded a specified
# execution time. The execution time does not include the I/O operations
# like talking with the client, sending the reply and so forth,
# but just the time needed to actually execute the command (this is the only
# stage of command execution where the thread is blocked and can not serve
# other requests in the meantime).
#
# You can configure the slow log with two parameters: one tells Vire
# what is the execution time, in microseconds, to exceed in order for the
# command to get logged, and the other parameter is the length of the
# slow log. When a new command is logged the oldest one is removed from the
# queue of logged commands.

# The following time is expressed in microseconds, so 1000000 is equivalent
# to one second. Note that a negative number disables the slow log, while
# a value of zero forces the logging of every command.
slowlog-log-slower-than 10000

# There is no limit to this length. Just be aware that it will consume memory.
# You can reclaim memory used by the slow log with SLOWLOG RESET.
slowlog-max-len 128

================================================
FILE: configure.ac
================================================
# Define the package version numbers and the bug reporting address
m4_define([VR_MAJOR], 1)
m4_define([VR_MINOR], 0)
m4_define([VR_PATCH], 0)
m4_define([VR_BUGS], [diguo58@gmail.com])

# Initialize autoconf
AC_PREREQ([2.63])
AC_INIT([vire], [VR_MAJOR.VR_MINOR.VR_PATCH], [VR_BUGS])
AC_CONFIG_SRCDIR([src/vr.c])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_HEADERS([config.h:config.h.in])
AC_CONFIG_MACRO_DIR([m4])

# Initialize automake
AM_INIT_AUTOMAKE([1.9 foreign])

# Define macro variables for the package version numbers
AC_DEFINE(VR_VERSION_MAJOR, VR_MAJOR, [Define the major version number])
AC_DEFINE(VR_VERSION_MINOR, VR_MINOR, [Define the minor version number])
AC_DEFINE(VR_VERSION_PATCH, VR_PATCH, [Define the patch version number])
AC_DEFINE(VR_VERSION_STRING, "VR_MAJOR.VR_MINOR.VR_PATCH", [Define the version string])

# Checks for language
AC_LANG([C])

# Checks for programs
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_LIBTOOL

# Checks for typedefs, structures, and compiler characteristics
AC_C_INLINE
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_INTMAX_T
AC_TYPE_INTPTR_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINTMAX_T
AC_TYPE_UINTPTR_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T

AC_C_BIGENDIAN(
  [],
  [AC_DEFINE(HAVE_LITTLE_ENDIAN, 1, [Define to 1 if machine is little endian])],
  [AC_MSG_ERROR([endianess of this machine is unknown])],
  [AC_MSG_ERROR([universial endianess not supported])]
)

# Checks for header files
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([fcntl.h float.h limits.h stddef.h stdlib.h string.h unistd.h])
AC_CHECK_HEADERS([inttypes.h stdint.h])
AC_CHECK_HEADERS([sys/ioctl.h sys/time.h sys/uio.h])
AC_CHECK_HEADERS([sys/socket.h sys/un.h netinet/in.h arpa/inet.h netdb.h])
AC_CHECK_HEADERS([execinfo.h],
  [AC_DEFINE(HAVE_BACKTRACE, [1], [Define to 1 if backtrace is supported])], [])
AC_CHECK_HEADERS([sys/epoll.h], [], [])
AC_CHECK_HEADERS([sys/event.h], [], [])

# Checks for libraries
AC_CHECK_LIB([m], [pow])
AC_CHECK_LIB([pthread], [pthread_create])

# Checks for library functions
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([dup2 gethostname gettimeofday strerror])
AC_CHECK_FUNCS([socket])
AC_CHECK_FUNCS([memchr memmove memset])
AC_CHECK_FUNCS([strchr strndup strtoul])

AC_CACHE_CHECK([if epoll works], [ac_cv_epoll_works],
  AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <sys/epoll.h>
int
main(int argc, char **argv)
{
    int fd;

    fd = epoll_create(256);
    if (fd < 0) {
        perror("epoll_create:");
        exit(1);
    }
    exit(0);
}
  ], [ac_cv_epoll_works=yes], [ac_cv_epoll_works=no]))
AS_IF([test "x$ac_cv_epoll_works" = "xyes"],
  [AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is supported])], [])

AC_CACHE_CHECK([if kqueue works], [ac_cv_kqueue_works],
  AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
int
main(int argc, char **argv)
{
    int fd;

    fd = kqueue();
    if (fd < 0) {
        perror("kqueue:");
        exit(1);
    }
    exit(0);
}
  ], [ac_cv_kqueue_works=yes], [ac_cv_kqueue_works=no]))
AS_IF([test "x$ac_cv_kqueue_works" = "xyes"],
  [AC_DEFINE([HAVE_KQUEUE], [1], [Define to 1 if kqueue is supported])], [])

AC_CACHE_CHECK([if event ports works], [ac_cv_evports_works],
  AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <port.h>
int
main(int argc, char **argv)
{
    int fd;

    fd = port_create();
    if (fd < 0) {
        perror("port_create:");
        exit(1);
    }
    exit(0);
}
  ], [ac_cv_evports_works=yes], [ac_cv_evports_works=no]))
AS_IF([test "x$ac_cv_evports_works" = "xyes"],
  [AC_DEFINE([HAVE_EVENT_PORTS], [1], [Define to 1 if event ports is supported])], [])

AS_IF([test "x$ac_cv_epoll_works" = "xno" &&
       test "x$ac_cv_kqueue_works" = "xno" &&
       test "x$ac_cv_evports_works" = "xno"],
  [AC_MSG_ERROR([either epoll or kqueue or event ports support is required])], [])

AM_CONDITIONAL([OS_LINUX], [test "x$ac_cv_epoll_works" = "xyes"])
AM_CONDITIONAL([OS_BSD], [test "x$ac_cv_kqueue_works" = "xyes"])
AM_CONDITIONAL([OS_SOLARIS], [test "x$ac_cv_evports_works" = "xyes"])
AM_CONDITIONAL([OS_FREEBSD], [test "$(uname -v | cut -c 1-10)" == "FreeBSD 10"])
AM_CONDITIONAL([OS_DARWIN], [test "$(uname -v | cut -c 1-6)" == "Darwin"])

# Package options
AC_MSG_CHECKING([whether to enable debug logs and asserts])
AC_ARG_ENABLE([debug],
  [AS_HELP_STRING(
    [--enable-debug=@<:@full|yes|log|no@:>@],
    [enable debug logs and asserts @<:@default=no@:>@])
  ],
  [],
  [enable_debug=no])
AS_CASE([x$enable_debug],
  [xfull], [AC_DEFINE([HAVE_ASSERT_PANIC], [1],
                      [Define to 1 if panic on an assert is enabled])
            AC_DEFINE([HAVE_DEBUG_LOG], [1], [Define to 1 if debug log is enabled])
           ],
  [xyes], [AC_DEFINE([HAVE_ASSERT_LOG], [1],
                     [Define to 1 if log on an assert is enabled])
           AC_DEFINE([HAVE_DEBUG_LOG], [1], [Define to 1 if debug log is enabled])
          ],
  [xlog], [AC_DEFINE([HAVE_DEBUG_LOG], [1], [Define to 1 if debug log is enabled])],
  [xno], [],
  [AC_MSG_FAILURE([invalid value ${enable_debug} for --enable-debug])])
AC_MSG_RESULT($enable_debug)

AC_MSG_CHECKING([whether to disable spinlock])
AC_ARG_ENABLE([spinlock],
  [AS_HELP_STRING(
    [--disable-spinlock],
    [disable spinlock])
  ],
  [disable_spinlock=yes],
  [disable_spinlock=no])
AS_IF([test "x$disable_spinlock" = xyes],
  [],
  [AC_DEFINE([HAVE_SPINLOCK], [1], [Define to 1 if spinlock is not disabled])])
AC_MSG_RESULT($disable_spinlock)

AC_MSG_CHECKING([whether to use jemalloc])
AC_ARG_WITH([jemalloc],
  AS_HELP_STRING([--with-jemalloc@<:@=yes|no@:>@],
    [use jemalloc(default use jemalloc)]),
  [
    if test "$withval" = "no"; then
      enable_jemalloc=no
    else
	  enable_jemalloc=yes
    fi
  ],
  [enable_jemalloc=yes])
AS_IF([test "x$enable_jemalloc" = xyes],
  [AC_DEFINE([HAVE_JEMALLOC], [1], [Define to 1 if jemalloc is used])],
  [])
AC_MSG_RESULT($enable_jemalloc)

# Untar the jemalloc-4.2.0.tar.bz2 in dep/ before config.status is rerun
# Run configure in dep/jemalloc-4.2.0
AC_CONFIG_COMMANDS_PRE([rm -rf dep/jemalloc-4.2.0])
AC_CONFIG_COMMANDS_PRE([mkdir dep/jemalloc-4.2.0])
AC_CONFIG_COMMANDS_PRE([tar xvjf dep/jemalloc-4.2.0.tar.bz2 -C dep])
AC_CONFIG_COMMANDS_PRE([cd dep/jemalloc-4.2.0])
AC_CONFIG_COMMANDS_PRE([./configure --with-jemalloc-prefix=je_])
AC_CONFIG_COMMANDS_PRE([cd ../..])

# Untar the hiredis-0.13.3.tar.gz in dep/ before config.status is rerun
AC_CONFIG_COMMANDS_PRE([rm -rf dep/hiredis-0.13.3])
AC_CONFIG_COMMANDS_PRE([mkdir dep/hiredis-0.13.3])
AC_CONFIG_COMMANDS_PRE([tar zxvf dep/hiredis-0.13.3.tar.gz -C dep])
AC_CONFIG_COMMANDS_PRE([cd dep/hiredis-0.13.3])
AC_CONFIG_COMMANDS_PRE([cd ../..])

# Define Makefiles
AC_CONFIG_FILES([Makefile
                 dep/Makefile
                 dep/util/Makefile
                 dep/dhashkit/Makefile
                 dep/dmalloc/Makefile
                 dep/sds/Makefile
                 dep/ae/Makefile
                 dep/dlist/Makefile
                 dep/darray/Makefile
                 dep/himemcached-0.1.0/Makefile
                 src/Makefile
                 tests/Makefile])

# Generate the "configure" script
AC_OUTPUT


================================================
FILE: dep/.gitignore
================================================
!*.tar.gz

================================================
FILE: dep/Makefile.am
================================================
SUBDIRS = jemalloc-4.2.0 hiredis-0.13.3 himemcached-0.1.0 util dhashkit dmalloc ae sds dlist darray

EXTRA_DIST = jemalloc-4.2.0.tar.bz2 hiredis-0.13.3.tar.gz


================================================
FILE: dep/ae/Makefile.am
================================================
MAINTAINERCLEANFILES = Makefile.in

AM_CPPFLAGS =
if !OS_SOLARIS
AM_CPPFLAGS += -D_GNU_SOURCE
endif
AM_CPPFLAGS += -I $(top_srcdir)/dep/util
AM_CPPFLAGS += -I $(top_srcdir)/dep/jemalloc-4.2.0/include
AM_CPPFLAGS += -I $(top_srcdir)/dep/dmalloc

AM_CFLAGS = -Wall -Wshadow
AM_CFLAGS += -Wno-unused-parameter -Wno-unused-value

noinst_LIBRARIES = libae.a

noinst_HEADERS = ae.h

libae_a_SOURCES =	\
	ae.c ae.h

================================================
FILE: dep/ae/ae.c
================================================
/* A simple event-driven programming library. Originally I wrote this code
 * for the Jim's event-loop (Jim is a Tcl interpreter) but later translated
 * it in form of a library for easy reuse.
 *
 * Copyright (c) 2006-2010, Salvatore Sanfilippo <antirez at gmail dot com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *   * Neither the name of Redis nor the names of its contributors may be used
 *     to endorse or promote products derived from this software without
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <poll.h>
#include <string.h>
#include <time.h>
#include <errno.h>

#include <dmalloc.h>

#include <ae.h>

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

/* Include the best multiplexing layer supported by this system.
 * The following should be ordered by performances, descending. */
#ifdef HAVE_EVENT_PORTS
#include "ae_evport.c"
#else
    #ifdef HAVE_EPOLL
    #include "ae_epoll.c"
    #else
        #ifdef HAVE_KQUEUE
        #include "ae_kqueue.c"
        #else
        #include "ae_select.c"
        #endif
    #endif
#endif

aeEventLoop *aeCreateEventLoop(int setsize) {
    aeEventLoop *eventLoop;
    int i;

    if ((eventLoop = dalloc(sizeof(*eventLoop))) == NULL) goto err;
    eventLoop->events = dalloc(sizeof(aeFileEvent)*setsize);
    eventLoop->fired = dalloc(sizeof(aeFiredEvent)*setsize);
    if (eventLoop->events == NULL || eventLoop->fired == NULL) goto err;
    eventLoop->setsize = setsize;
    eventLoop->lastTime = time(NULL);
    eventLoop->timeEventHead = NULL;
    eventLoop->timeEventNextId = 0;
    eventLoop->stop = 0;
    eventLoop->maxfd = -1;
    eventLoop->beforesleep = NULL;
    eventLoop->bsdata = NULL;
    if (aeApiCreate(eventLoop) == -1) goto err;
    /* Events with mask == AE_NONE are not set. So let's initialize the
     * vector with it. */
    for (i = 0; i < setsize; i++)
        eventLoop->events[i].mask = AE_NONE;
    return eventLoop;

err:
    if (eventLoop) {
        dfree(eventLoop->events);
        dfree(eventLoop->fired);
        dfree(eventLoop);
    }
    return NULL;
}

/* Return the current set size. */
int aeGetSetSize(aeEventLoop *eventLoop) {
    return eventLoop->setsize;
}

/* Resize the maximum set size of the event loop.
 * If the requested set size is smaller than the current set size, but
 * there is already a file descriptor in use that is >= the requested
 * set size minus one, AE_ERR is returned and the operation is not
 * performed at all.
 *
 * Otherwise AE_OK is returned and the operation is successful. */
int aeResizeSetSize(aeEventLoop *eventLoop, int setsize) {
    int i;

    if (setsize == eventLoop->setsize) return AE_OK;
    if (eventLoop->maxfd >= setsize) return AE_ERR;
    if (aeApiResize(eventLoop,setsize) == -1) return AE_ERR;

    eventLoop->events = drealloc(eventLoop->events,sizeof(aeFileEvent)*setsize);
    eventLoop->fired = drealloc(eventLoop->fired,sizeof(aeFiredEvent)*setsize);
    eventLoop->setsize = setsize;

    /* Make sure that if we created new slots, they are initialized with
     * an AE_NONE mask. */
    for (i = eventLoop->maxfd+1; i < setsize; i++)
        eventLoop->events[i].mask = AE_NONE;
    return AE_OK;
}

void aeDeleteEventLoop(aeEventLoop *eventLoop) {
    aeApiFree(eventLoop);
    dfree(eventLoop->events);
    dfree(eventLoop->fired);
    dfree(eventLoop);
}

void aeStop(aeEventLoop *eventLoop) {
    eventLoop->stop = 1;
}

int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask,
        aeFileProc *proc, void *clientData)
{
    if (fd >= eventLoop->setsize) {
        if (aeResizeSetSize(eventLoop,fd+1000) != AE_OK) {
            return AE_ERR;
        }
    }
    aeFileEvent *fe = &eventLoop->events[fd];

    if (aeApiAddEvent(eventLoop, fd, mask) == -1)
        return AE_ERR;
    fe->mask |= mask;
    if (mask & AE_READABLE) fe->rfileProc = proc;
    if (mask & AE_WRITABLE) fe->wfileProc = proc;
    fe->clientData = clientData;
    if (fd > eventLoop->maxfd)
        eventLoop->maxfd = fd;
    return AE_OK;
}

void aeDeleteFileEvent(aeEventLoop *eventLoop, int fd, int mask)
{
    if (fd >= eventLoop->setsize) return;
    aeFileEvent *fe = &eventLoop->events[fd];
    if (fe->mask == AE_NONE) return;

    aeApiDelEvent(eventLoop, fd, mask);
    fe->mask = fe->mask & (~mask);
    if (fd == eventLoop->maxfd && fe->mask == AE_NONE) {
        /* Update the max fd */
        int j;

        for (j = eventLoop->maxfd-1; j >= 0; j--)
            if (eventLoop->events[j].mask != AE_NONE) break;
        eventLoop->maxfd = j;
    }
}

int aeGetFileEvents(aeEventLoop *eventLoop, int fd) {
    if (fd >= eventLoop->setsize) return 0;
    aeFileEvent *fe = &eventLoop->events[fd];

    return fe->mask;
}

static void aeGetTime(long *seconds, long *milliseconds)
{
    struct timeval tv;

    gettimeofday(&tv, NULL);
    *seconds = tv.tv_sec;
    *milliseconds = tv.tv_usec/1000;
}

static void aeAddMillisecondsToNow(long long milliseconds, long *sec, long *ms) {
    long cur_sec, cur_ms, when_sec, when_ms;

    aeGetTime(&cur_sec, &cur_ms);
    when_sec = cur_sec + milliseconds/1000;
    when_ms = cur_ms + milliseconds%1000;
    if (when_ms >= 1000) {
        when_sec ++;
        when_ms -= 1000;
    }
    *sec = when_sec;
    *ms = when_ms;
}

long long aeCreateTimeEvent(aeEventLoop *eventLoop, long long milliseconds,
        aeTimeProc *proc, void *clientData,
        aeEventFinalizerProc *finalizerProc)
{
    long long id = eventLoop->timeEventNextId++;
    aeTimeEvent *te;

    te = dalloc(sizeof(*te));
    if (te == NULL) return AE_ERR;
    te->id = id;
    aeAddMillisecondsToNow(milliseconds,&te->when_sec,&te->when_ms);
    te->timeProc = proc;
    te->finalizerProc = finalizerProc;
    te->clientData = clientData;
    te->next = eventLoop->timeEventHead;
    eventLoop->timeEventHead = te;
    return id;
}

int aeDeleteTimeEvent(aeEventLoop *eventLoop, long long id)
{
    aeTimeEvent *te = eventLoop->timeEventHead;
    while(te) {
        if (te->id == id) {
            te->id = AE_DELETED_EVENT_ID;
            return AE_OK;
        }
        te = te->next;
    }
    return AE_ERR; /* NO event with the specified ID found */
}

/* Search the first timer to fire.
 * This operation is useful to know how many time the select can be
 * put in sleep without to delay any event.
 * If there are no timers NULL is returned.
 *
 * Note that's O(N) since time events are unsorted.
 * Possible optimizations (not needed by Redis so far, but...):
 * 1) Insert the event in order, so that the nearest is just the head.
 *    Much better but still insertion or deletion of timers is O(N).
 * 2) Use a skiplist to have this operation as O(1) and insertion as O(log(N)).
 */
static aeTimeEvent *aeSearchNearestTimer(aeEventLoop *eventLoop)
{
    aeTimeEvent *te = eventLoop->timeEventHead;
    aeTimeEvent *nearest = NULL;

    while(te) {
        if (!nearest || te->when_sec < nearest->when_sec ||
                (te->when_sec == nearest->when_sec &&
                 te->when_ms < nearest->when_ms))
            nearest = te;
        te = te->next;
    }
    return nearest;
}

/* Process time events */
static int processTimeEvents(aeEventLoop *eventLoop) {
    int processed = 0;
    aeTimeEvent *te, *prev;
    long long maxId;
    time_t now = time(NULL);

    /* If the system clock is moved to the future, and then set back to the
     * right value, time events may be delayed in a random way. Often this
     * means that scheduled operations will not be performed soon enough.
     *
     * Here we try to detect system clock skews, and force all the time
     * events to be processed ASAP when this happens: the idea is that
     * processing events earlier is less dangerous than delaying them
     * indefinitely, and practice suggests it is. */
    if (now < eventLoop->lastTime) {
        te = eventLoop->timeEventHead;
        while(te) {
            te->when_sec = 0;
            te = te->next;
        }
    }
    eventLoop->lastTime = now;

    prev = NULL;
    te = eventLoop->timeEventHead;
    maxId = eventLoop->timeEventNextId-1;
    while(te) {
        long now_sec, now_ms;
        long long id;

        /* Remove events scheduled for deletion. */
        if (te->id == AE_DELETED_EVENT_ID) {
            aeTimeEvent *next = te->next;
            if (prev == NULL)
                eventLoop->timeEventHead = te->next;
            else
                prev->next = te->next;
            if (te->finalizerProc)
                te->finalizerProc(eventLoop, te->clientData);
            dfree(te);
            te = next;
            continue;
        }

        /* Make sure we don't process time events created by time events in
         * this iteration. Note that this check is currently useless: we always
         * add new timers on the head, however if we change the implementation
         * detail, this check may be useful again: we keep it here for future
         * defense. */
        if (te->id > maxId) {
            te = te->next;
            continue;
        }
        aeGetTime(&now_sec, &now_ms);
        if (now_sec > te->when_sec ||
            (now_sec == te->when_sec && now_ms >= te->when_ms))
        {
            int retval;

            id = te->id;
            retval = te->timeProc(eventLoop, id, te->clientData);
            processed++;
            if (retval != AE_NOMORE) {
                aeAddMillisecondsToNow(retval,&te->when_sec,&te->when_ms);
            } else {
                te->id = AE_DELETED_EVENT_ID;
            }
        }
        prev = te;
        te = te->next;
    }
    return processed;
}

/* Process every pending time event, then every pending file event
 * (that may be registered by time event callbacks just processed).
 * Without special flags the function sleeps until some file event
 * fires, or when the next time event occurs (if any).
 *
 * If flags is 0, the function does nothing and returns.
 * if flags has AE_ALL_EVENTS set, all the kind of events are processed.
 * if flags has AE_FILE_EVENTS set, file events are processed.
 * if flags has AE_TIME_EVENTS set, time events are processed.
 * if flags has AE_DONT_WAIT set the function returns ASAP until all
 * the events that's possible to process without to wait are processed.
 *
 * The function returns the number of events processed. */
int aeProcessEvents(aeEventLoop *eventLoop, int flags)
{
    int processed = 0, numevents;

    /* Nothing to do? return ASAP */
    if (!(flags & AE_TIME_EVENTS) && !(flags & AE_FILE_EVENTS)) return 0;

    /* Note that we want call select() even if there are no
     * file events to process as long as we want to process time
     * events, in order to sleep until the next time event is ready
     * to fire. */
    if (eventLoop->maxfd != -1 ||
        ((flags & AE_TIME_EVENTS) && !(flags & AE_DONT_WAIT))) {
        int j;
        aeTimeEvent *shortest = NULL;
        struct timeval tv, *tvp;

        if (flags & AE_TIME_EVENTS && !(flags & AE_DONT_WAIT))
            shortest = aeSearchNearestTimer(eventLoop);
        if (shortest) {
            long now_sec, now_ms;

            aeGetTime(&now_sec, &now_ms);
            tvp = &tv;

            /* How many milliseconds we need to wait for the next
             * time event to fire? */
            long long ms =
                (shortest->when_sec - now_sec)*1000 +
                shortest->when_ms - now_ms;

            if (ms > 0) {
                tvp->tv_sec = ms/1000;
                tvp->tv_usec = (ms % 1000)*1000;
            } else {
                tvp->tv_sec = 0;
                tvp->tv_usec = 0;
            }
        } else {
            /* If we have to check for events but need to return
             * ASAP because of AE_DONT_WAIT we need to set the timeout
             * to zero */
            if (flags & AE_DONT_WAIT) {
                tv.tv_sec = tv.tv_usec = 0;
                tvp = &tv;
            } else {
                /* Otherwise we can block */
                tvp = NULL; /* wait forever */
            }
        }

        numevents = aeApiPoll(eventLoop, tvp);
        for (j = 0; j < numevents; j++) {
            aeFileEvent *fe = &eventLoop->events[eventLoop->fired[j].fd];
            int mask = eventLoop->fired[j].mask;
            int fd = eventLoop->fired[j].fd;
            int rfired = 0;

	    /* note the fe->mask & mask & ... code: maybe an already processed
             * event removed an element that fired and we still didn't
             * processed, so we check if the event is still valid. */
            if (fe->mask & mask & AE_READABLE) {
                rfired = 1;
                fe->rfileProc(eventLoop,fd,fe->clientData,mask);
            }
            if (fe->mask & mask & AE_WRITABLE) {
                if (!rfired || fe->wfileProc != fe->rfileProc)
                    fe->wfileProc(eventLoop,fd,fe->clientData,mask);
            }
            processed++;
        }
    }
    /* Check time events */
    if (flags & AE_TIME_EVENTS)
        processed += processTimeEvents(eventLoop);

    return processed; /* return the number of processed file/time events */
}

/* Wait for milliseconds until the given file descriptor becomes
 * writable/readable/exception */
int aeWait(int fd, int mask, long long milliseconds) {
    struct pollfd pfd;
    int retmask = 0, retval;

    memset(&pfd, 0, sizeof(pfd));
    pfd.fd = fd;
    if (mask & AE_READABLE) pfd.events |= POLLIN;
    if (mask & AE_WRITABLE) pfd.events |= POLLOUT;

    if ((retval = poll(&pfd, 1, milliseconds))== 1) {
        if (pfd.revents & POLLIN) retmask |= AE_READABLE;
        if (pfd.revents & POLLOUT) retmask |= AE_WRITABLE;
	if (pfd.revents & POLLERR) retmask |= AE_WRITABLE;
        if (pfd.revents & POLLHUP) retmask |= AE_WRITABLE;
        return retmask;
    } else {
        return retval;
    }
}

void aeMain(aeEventLoop *eventLoop) {
    eventLoop->stop = 0;
    while (!eventLoop->stop) {
        if (eventLoop->beforesleep != NULL)
            eventLoop->beforesleep(eventLoop, eventLoop->bsdata);
        aeProcessEvents(eventLoop, AE_ALL_EVENTS);
    }
}

char *aeGetApiName(void) {
    return aeApiName();
}

void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep, void *private_data) {
    eventLoop->beforesleep = beforesleep;
    eventLoop->bsdata = private_data;
}


================================================
FILE: dep/ae/ae.h
================================================
/* A simple event-driven programming library. Originally I wrote this code
 * for the Jim's event-loop (Jim is a Tcl interpreter) but later translated
 * it in form of a library for easy reuse.
 *
 * Copyright (c) 2006-2012, Salvatore Sanfilippo <antirez at gmail dot com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *   * Neither the name of Redis nor the names of its contributors may be used
 *     to endorse or promote products derived from this software without
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __AE_H__
#define __AE_H__

#include <time.h>

#define AE_OK 0
#define AE_ERR -1

#define AE_NONE 0
#define AE_READABLE 1
#define AE_WRITABLE 2

#define AE_FILE_EVENTS 1
#define AE_TIME_EVENTS 2
#define AE_ALL_EVENTS (AE_FILE_EVENTS|AE_TIME_EVENTS)
#define AE_DONT_WAIT 4

#define AE_NOMORE -1
#define AE_DELETED_EVENT_ID -1

/* Macros */
#define AE_NOTUSED(V) ((void) V)

struct aeEventLoop;

/* Types and data structures */
typedef void aeFileProc(struct aeEventLoop *eventLoop, int fd, void *clientData, int mask);
typedef int aeTimeProc(struct aeEventLoop *eventLoop, long long id, void *clientData);
typedef void aeEventFinalizerProc(struct aeEventLoop *eventLoop, void *clientData);
typedef void aeBeforeSleepProc(struct aeEventLoop *eventLoop, void *private_data);

/* File event structure */
typedef struct aeFileEvent {
    int mask; /* one of AE_(READABLE|WRITABLE) */
    aeFileProc *rfileProc;
    aeFileProc *wfileProc;
    void *clientData;
} aeFileEvent;

/* Time event structure */
typedef struct aeTimeEvent {
    long long id; /* time event identifier. */
    long when_sec; /* seconds */
    long when_ms; /* milliseconds */
    aeTimeProc *timeProc;
    aeEventFinalizerProc *finalizerProc;
    void *clientData;
    struct aeTimeEvent *next;
} aeTimeEvent;

/* A fired event */
typedef struct aeFiredEvent {
    int fd;
    int mask;
} aeFiredEvent;

/* State of an event based program */
typedef struct aeEventLoop {
    int maxfd;   /* highest file descriptor currently registered */
    int setsize; /* max number of file descriptors tracked */
    long long timeEventNextId;
    time_t lastTime;     /* Used to detect system clock skew */
    aeFileEvent *events; /* Registered events */
    aeFiredEvent *fired; /* Fired events */
    aeTimeEvent *timeEventHead;
    int stop;
    void *apidata; /* This is used for polling API specific data */
    aeBeforeSleepProc *beforesleep;
    void *bsdata; /* This is used for beforesleep private data */
} aeEventLoop;

/* Prototypes */
aeEventLoop *aeCreateEventLoop(int setsize);
void aeDeleteEventLoop(aeEventLoop *eventLoop);
void aeStop(aeEventLoop *eventLoop);
int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask,
        aeFileProc *proc, void *clientData);
void aeDeleteFileEvent(aeEventLoop *eventLoop, int fd, int mask);
int aeGetFileEvents(aeEventLoop *eventLoop, int fd);
long long aeCreateTimeEvent(aeEventLoop *eventLoop, long long milliseconds,
        aeTimeProc *proc, void *clientData,
        aeEventFinalizerProc *finalizerProc);
int aeDeleteTimeEvent(aeEventLoop *eventLoop, long long id);
int aeProcessEvents(aeEventLoop *eventLoop, int flags);
int aeWait(int fd, int mask, long long milliseconds);
void aeMain(aeEventLoop *eventLoop);
char *aeGetApiName(void);
void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep, void *private_data);
int aeGetSetSize(aeEventLoop *eventLoop);
int aeResizeSetSize(aeEventLoop *eventLoop, int setsize);

#endif


================================================
FILE: dep/ae/ae_epoll.c
================================================
/* Linux epoll(2) based ae.c module
 *
 * Copyright (c) 2009-2012, Salvatore Sanfilippo <antirez at gmail dot com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *   * Neither the name of Redis nor the names of its contributors may be used
 *     to endorse or promote products derived from this software without
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


#include <sys/epoll.h>

typedef struct aeApiState {
    int epfd;
    struct epoll_event *events;
} aeApiState;

static int aeApiCreate(aeEventLoop *eventLoop) {
    aeApiState *state = dalloc(sizeof(aeApiState));

    if (!state) return -1;
    state->events = dalloc(sizeof(struct epoll_event)*eventLoop->setsize);
    if (!state->events) {
        dfree(state);
        return -1;
    }
    state->epfd = epoll_create(1024); /* 1024 is just a hint for the kernel */
    if (state->epfd == -1) {
        dfree(state->events);
        dfree(state);
        return -1;
    }
    eventLoop->apidata = state;
    return 0;
}

static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
    aeApiState *state = eventLoop->apidata;

    state->events = drealloc(state->events, sizeof(struct epoll_event)*setsize);
    return 0;
}

static void aeApiFree(aeEventLoop *eventLoop) {
    aeApiState *state = eventLoop->apidata;

    close(state->epfd);
    dfree(state->events);
    dfree(state);
}

static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
    aeApiState *state = eventLoop->apidata;
    struct epoll_event ee = {0}; /* avoid valgrind warning */
    /* If the fd was already monitored for some event, we need a MOD
     * operation. Otherwise we need an ADD operation. */
    int op = eventLoop->events[fd].mask == AE_NONE ?
            EPOLL_CTL_ADD : EPOLL_CTL_MOD;

    ee.events = 0;
    mask |= eventLoop->events[fd].mask; /* Merge old events */
    if (mask & AE_READABLE) ee.events |= EPOLLIN;
    if (mask & AE_WRITABLE) ee.events |= EPOLLOUT;
    ee.data.fd = fd;
    if (epoll_ctl(state->epfd,op,fd,&ee) == -1) return -1;
    return 0;
}

static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int delmask) {
    aeApiState *state = eventLoop->apidata;
    struct epoll_event ee = {0}; /* avoid valgrind warning */
    int mask = eventLoop->events[fd].mask & (~delmask);

    ee.events = 0;
    if (mask & AE_READABLE) ee.events |= EPOLLIN;
    if (mask & AE_WRITABLE) ee.events |= EPOLLOUT;
    ee.data.fd = fd;
    if (mask != AE_NONE) {
        epoll_ctl(state->epfd,EPOLL_CTL_MOD,fd,&ee);
    } else {
        /* Note, Kernel < 2.6.9 requires a non null event pointer even for
         * EPOLL_CTL_DEL. */
        epoll_ctl(state->epfd,EPOLL_CTL_DEL,fd,&ee);
    }
}

static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) {
    aeApiState *state = eventLoop->apidata;
    int retval, numevents = 0;

    retval = epoll_wait(state->epfd,state->events,eventLoop->setsize,
            tvp ? (tvp->tv_sec*1000 + tvp->tv_usec/1000) : -1);
    if (retval > 0) {
        int j;

        numevents = retval;
        for (j = 0; j < numevents; j++) {
            int mask = 0;
            struct epoll_event *e = state->events+j;

            if (e->events & EPOLLIN) mask |= AE_READABLE;
            if (e->events & EPOLLOUT) mask |= AE_WRITABLE;
            if (e->events & EPOLLERR) mask |= AE_WRITABLE;
            if (e->events & EPOLLHUP) mask |= AE_WRITABLE;
            eventLoop->fired[j].fd = e->data.fd;
            eventLoop->fired[j].mask = mask;
        }
    }
    return numevents;
}

static char *aeApiName(void) {
    return "epoll";
}


================================================
FILE: dep/ae/ae_evport.c
================================================
/* ae.c module for illumos event ports.
 *
 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *   * Neither the name of Redis nor the names of its contributors may be used
 *     to endorse or promote products derived from this software without
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


#include <assert.h>
#include <errno.h>
#include <port.h>
#include <poll.h>

#include <sys/types.h>
#include <sys/time.h>

#include <stdio.h>

static int evport_debug = 0;

/*
 * This file implements the ae API using event ports, present on Solaris-based
 * systems since Solaris 10.  Using the event port interface, we associate file
 * descriptors with the port.  Each association also includes the set of poll(2)
 * events that the consumer is interested in (e.g., POLLIN and POLLOUT).
 *
 * There's one tricky piece to this implementation: when we return events via
 * aeApiPoll, the corresponding file descriptors become dissociated from the
 * port.  This is necessary because poll events are level-triggered, so if the
 * fd didn't become dissociated, it would immediately fire another event since
 * the underlying state hasn't changed yet.  We must re-associate the file
 * descriptor, but only after we know that our caller has actually read from it.
 * The ae API does not tell us exactly when that happens, but we do know that
 * it must happen by the time aeApiPoll is called again.  Our solution is to
 * keep track of the last fds returned by aeApiPoll and re-associate them next
 * time aeApiPoll is invoked.
 *
 * To summarize, in this module, each fd association is EITHER (a) represented
 * only via the in-kernel association OR (b) represented by pending_fds and
 * pending_masks.  (b) is only true for the last fds we returned from aeApiPoll,
 * and only until we enter aeApiPoll again (at which point we restore the
 * in-kernel association).
 */
#define MAX_EVENT_BATCHSZ 512

typedef struct aeApiState {
    int     portfd;                             /* event port */
    int     npending;                           /* # of pending fds */
    int     pending_fds[MAX_EVENT_BATCHSZ];     /* pending fds */
    int     pending_masks[MAX_EVENT_BATCHSZ];   /* pending fds' masks */
} aeApiState;

static int aeApiCreate(aeEventLoop *eventLoop) {
    int i;
    aeApiState *state = dalloc(sizeof(aeApiState));
    if (!state) return -1;

    state->portfd = port_create();
    if (state->portfd == -1) {
        dfree(state);
        return -1;
    }

    state->npending = 0;

    for (i = 0; i < MAX_EVENT_BATCHSZ; i++) {
        state->pending_fds[i] = -1;
        state->pending_masks[i] = AE_NONE;
    }

    eventLoop->apidata = state;
    return 0;
}

static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
    /* Nothing to resize here. */
    return 0;
}

static void aeApiFree(aeEventLoop *eventLoop) {
    aeApiState *state = eventLoop->apidata;

    close(state->portfd);
    dfree(state);
}

static int aeApiLookupPending(aeApiState *state, int fd) {
    int i;

    for (i = 0; i < state->npending; i++) {
        if (state->pending_fds[i] == fd)
            return (i);
    }

    return (-1);
}

/*
 * Helper function to invoke port_associate for the given fd and mask.
 */
static int aeApiAssociate(const char *where, int portfd, int fd, int mask) {
    int events = 0;
    int rv, err;

    if (mask & AE_READABLE)
        events |= POLLIN;
    if (mask & AE_WRITABLE)
        events |= POLLOUT;

    if (evport_debug)
        fprintf(stderr, "%s: port_associate(%d, 0x%x) = ", where, fd, events);

    rv = port_associate(portfd, PORT_SOURCE_FD, fd, events,
        (void *)(uintptr_t)mask);
    err = errno;

    if (evport_debug)
        fprintf(stderr, "%d (%s)\n", rv, rv == 0 ? "no error" : strerror(err));

    if (rv == -1) {
        fprintf(stderr, "%s: port_associate: %s\n", where, strerror(err));

        if (err == EAGAIN)
            fprintf(stderr, "aeApiAssociate: event port limit exceeded.");
    }

    return rv;
}

static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
    aeApiState *state = eventLoop->apidata;
    int fullmask, pfd;

    if (evport_debug)
        fprintf(stderr, "aeApiAddEvent: fd %d mask 0x%x\n", fd, mask);

    /*
     * Since port_associate's "events" argument replaces any existing events, we
     * must be sure to include whatever events are already associated when
     * we call port_associate() again.
     */
    fullmask = mask | eventLoop->events[fd].mask;
    pfd = aeApiLookupPending(state, fd);

    if (pfd != -1) {
        /*
         * This fd was recently returned from aeApiPoll.  It should be safe to
         * assume that the consumer has processed that poll event, but we play
         * it safer by simply updating pending_mask.  The fd will be
         * re-associated as usual when aeApiPoll is called again.
         */
        if (evport_debug)
            fprintf(stderr, "aeApiAddEvent: adding to pending fd %d\n", fd);
        state->pending_masks[pfd] |= fullmask;
        return 0;
    }

    return (aeApiAssociate("aeApiAddEvent", state->portfd, fd, fullmask));
}

static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int mask) {
    aeApiState *state = eventLoop->apidata;
    int fullmask, pfd;

    if (evport_debug)
        fprintf(stderr, "del fd %d mask 0x%x\n", fd, mask);

    pfd = aeApiLookupPending(state, fd);

    if (pfd != -1) {
        if (evport_debug)
            fprintf(stderr, "deleting event from pending fd %d\n", fd);

        /*
         * This fd was just returned from aeApiPoll, so it's not currently
         * associated with the port.  All we need to do is update
         * pending_mask appropriately.
         */
        state->pending_masks[pfd] &= ~mask;

        if (state->pending_masks[pfd] == AE_NONE)
            state->pending_fds[pfd] = -1;

        return;
    }

    /*
     * The fd is currently associated with the port.  Like with the add case
     * above, we must look at the full mask for the file descriptor before
     * updating that association.  We don't have a good way of knowing what the
     * events are without looking into the eventLoop state directly.  We rely on
     * the fact that our caller has already updated the mask in the eventLoop.
     */

    fullmask = eventLoop->events[fd].mask;
    if (fullmask == AE_NONE) {
        /*
         * We're removing *all* events, so use port_dissociate to remove the
         * association completely.  Failure here indicates a bug.
         */
        if (evport_debug)
            fprintf(stderr, "aeApiDelEvent: port_dissociate(%d)\n", fd);

        if (port_dissociate(state->portfd, PORT_SOURCE_FD, fd) != 0) {
            perror("aeApiDelEvent: port_dissociate");
            abort(); /* will not return */
        }
    } else if (aeApiAssociate("aeApiDelEvent", state->portfd, fd,
        fullmask) != 0) {
        /*
         * ENOMEM is a potentially transient condition, but the kernel won't
         * generally return it unless things are really bad.  EAGAIN indicates
         * we've reached an resource limit, for which it doesn't make sense to
         * retry (counter-intuitively).  All other errors indicate a bug.  In any
         * of these cases, the best we can do is to abort.
         */
        abort(); /* will not return */
    }
}

static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) {
    aeApiState *state = eventLoop->apidata;
    struct timespec timeout, *tsp;
    int mask, i;
    uint_t nevents;
    port_event_t event[MAX_EVENT_BATCHSZ];

    /*
     * If we've returned fd events before, we must re-associate them with the
     * port now, before calling port_get().  See the block comment at the top of
     * this file for an explanation of why.
     */
    for (i = 0; i < state->npending; i++) {
        if (state->pending_fds[i] == -1)
            /* This fd has since been deleted. */
            continue;

        if (aeApiAssociate("aeApiPoll", state->portfd,
            state->pending_fds[i], state->pending_masks[i]) != 0) {
            /* See aeApiDelEvent for why this case is fatal. */
            abort();
        }

        state->pending_masks[i] = AE_NONE;
        state->pending_fds[i] = -1;
    }

    state->npending = 0;

    if (tvp != NULL) {
        timeout.tv_sec = tvp->tv_sec;
        timeout.tv_nsec = tvp->tv_usec * 1000;
        tsp = &timeout;
    } else {
        tsp = NULL;
    }

    /*
     * port_getn can return with errno == ETIME having returned some events (!).
     * So if we get ETIME, we check nevents, too.
     */
    nevents = 1;
    if (port_getn(state->portfd, event, MAX_EVENT_BATCHSZ, &nevents,
        tsp) == -1 && (errno != ETIME || nevents == 0)) {
        if (errno == ETIME || errno == EINTR)
            return 0;

        /* Any other error indicates a bug. */
        perror("aeApiPoll: port_get");
        abort();
    }

    state->npending = nevents;

    for (i = 0; i < nevents; i++) {
            mask = 0;
            if (event[i].portev_events & POLLIN)
                mask |= AE_READABLE;
            if (event[i].portev_events & POLLOUT)
                mask |= AE_WRITABLE;

            eventLoop->fired[i].fd = event[i].portev_object;
            eventLoop->fired[i].mask = mask;

            if (evport_debug)
                fprintf(stderr, "aeApiPoll: fd %d mask 0x%x\n",
                    (int)event[i].portev_object, mask);

            state->pending_fds[i] = event[i].portev_object;
            state->pending_masks[i] = (uintptr_t)event[i].portev_user;
    }

    return nevents;
}

static char *aeApiName(void) {
    return "evport";
}


================================================
FILE: dep/ae/ae_kqueue.c
================================================
/* Kqueue(2)-based ae.c module
 *
 * Copyright (C) 2009 Harish Mallipeddi - harish.mallipeddi@gmail.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *   * Neither the name of Redis nor the names of its contributors may be used
 *     to endorse or promote products derived from this software without
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>

typedef struct aeApiState {
    int kqfd;
    struct kevent *events;
} aeApiState;

static int aeApiCreate(aeEventLoop *eventLoop) {
    aeApiState *state = dalloc(sizeof(aeApiState));

    if (!state) return -1;
    state->events = dalloc(sizeof(struct kevent)*eventLoop->setsize);
    if (!state->events) {
        dfree(state);
        return -1;
    }
    state->kqfd = kqueue();
    if (state->kqfd == -1) {
        dfree(state->events);
        dfree(state);
        return -1;
    }
    eventLoop->apidata = state;
    return 0;
}

static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
    aeApiState *state = eventLoop->apidata;

    state->events = drealloc(state->events, sizeof(struct kevent)*setsize);
    return 0;
}

static void aeApiFree(aeEventLoop *eventLoop) {
    aeApiState *state = eventLoop->apidata;

    close(state->kqfd);
    dfree(state->events);
    dfree(state);
}

static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
    aeApiState *state = eventLoop->apidata;
    struct kevent ke;

    if (mask & AE_READABLE) {
        EV_SET(&ke, fd, EVFILT_READ, EV_ADD, 0, 0, NULL);
        if (kevent(state->kqfd, &ke, 1, NULL, 0, NULL) == -1) return -1;
    }
    if (mask & AE_WRITABLE) {
        EV_SET(&ke, fd, EVFILT_WRITE, EV_ADD, 0, 0, NULL);
        if (kevent(state->kqfd, &ke, 1, NULL, 0, NULL) == -1) return -1;
    }
    return 0;
}

static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int mask) {
    aeApiState *state = eventLoop->apidata;
    struct kevent ke;

    if (mask & AE_READABLE) {
        EV_SET(&ke, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL);
        kevent(state->kqfd, &ke, 1, NULL, 0, NULL);
    }
    if (mask & AE_WRITABLE) {
        EV_SET(&ke, fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
        kevent(state->kqfd, &ke, 1, NULL, 0, NULL);
    }
}

static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) {
    aeApiState *state = eventLoop->apidata;
    int retval, numevents = 0;

    if (tvp != NULL) {
        struct timespec timeout;
        timeout.tv_sec = tvp->tv_sec;
        timeout.tv_nsec = tvp->tv_usec * 1000;
        retval = kevent(state->kqfd, NULL, 0, state->events, eventLoop->setsize,
                        &timeout);
    } else {
        retval = kevent(state->kqfd, NULL, 0, state->events, eventLoop->setsize,
                        NULL);
    }

    if (retval > 0) {
        int j;

        numevents = retval;
        for(j = 0; j < numevents; j++) {
            int mask = 0;
            struct kevent *e = state->events+j;

            if (e->filter == EVFILT_READ) mask |= AE_READABLE;
            if (e->filter == EVFILT_WRITE) mask |= AE_WRITABLE;
            eventLoop->fired[j].fd = e->ident;
            eventLoop->fired[j].mask = mask;
        }
    }
    return numevents;
}

static char *aeApiName(void) {
    return "kqueue";
}


================================================
FILE: dep/ae/ae_select.c
================================================
/* Select()-based ae.c module.
 *
 * Copyright (c) 2009-2012, Salvatore Sanfilippo <antirez at gmail dot com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *   * Neither the name of Redis nor the names of its contributors may be used
 *     to endorse or promote products derived from this software without
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


#include <string.h>

typedef struct aeApiState {
    fd_set rfds, wfds;
    /* We need to have a copy of the fd sets as it's not safe to reuse
     * FD sets after select(). */
    fd_set _rfds, _wfds;
} aeApiState;

static int aeApiCreate(aeEventLoop *eventLoop) {
    aeApiState *state = dalloc(sizeof(aeApiState));

    if (!state) return -1;
    FD_ZERO(&state->rfds);
    FD_ZERO(&state->wfds);
    eventLoop->apidata = state;
    return 0;
}

static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
    /* Just ensure we have enough room in the fd_set type. */
    if (setsize >= FD_SETSIZE) return -1;
    return 0;
}

static void aeApiFree(aeEventLoop *eventLoop) {
    dfree(eventLoop->apidata);
}

static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
    aeApiState *state = eventLoop->apidata;

    if (mask & AE_READABLE) FD_SET(fd,&state->rfds);
    if (mask & AE_WRITABLE) FD_SET(fd,&state->wfds);
    return 0;
}

static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int mask) {
    aeApiState *state = eventLoop->apidata;

    if (mask & AE_READABLE) FD_CLR(fd,&state->rfds);
    if (mask & AE_WRITABLE) FD_CLR(fd,&state->wfds);
}

static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) {
    aeApiState *state = eventLoop->apidata;
    int retval, j, numevents = 0;

    memcpy(&state->_rfds,&state->rfds,sizeof(fd_set));
    memcpy(&state->_wfds,&state->wfds,sizeof(fd_set));

    retval = select(eventLoop->maxfd+1,
                &state->_rfds,&state->_wfds,NULL,tvp);
    if (retval > 0) {
        for (j = 0; j <= eventLoop->maxfd; j++) {
            int mask = 0;
            aeFileEvent *fe = &eventLoop->events[j];

            if (fe->mask == AE_NONE) continue;
            if (fe->mask & AE_READABLE && FD_ISSET(j,&state->_rfds))
                mask |= AE_READABLE;
            if (fe->mask & AE_WRITABLE && FD_ISSET(j,&state->_wfds))
                mask |= AE_WRITABLE;
            eventLoop->fired[numevents].fd = j;
            eventLoop->fired[numevents].mask = mask;
            numevents++;
        }
    }
    return numevents;
}

static char *aeApiName(void) {
    return "select";
}


================================================
FILE: dep/darray/Makefile.am
================================================
MAINTAINERCLEANFILES = Makefile.in

AM_CPPFLAGS =
if !OS_SOLARIS
AM_CPPFLAGS += -D_GNU_SOURCE
endif
AM_CPPFLAGS += -I $(top_srcdir)/dep/util
AM_CPPFLAGS += -I $(top_srcdir)/dep/jemalloc-4.2.0/include
AM_CPPFLAGS += -I $(top_srcdir)/dep/dmalloc

AM_CFLAGS = -Wall -Wshadow
AM_CFLAGS += -Wno-unused-parameter -Wno-unused-value

noinst_LIBRARIES = libdarray.a

noinst_HEADERS = darray.h

libdarray_a_SOURCES = \
	darray.c darray.h

================================================
FILE: dep/darray/darray.c
================================================
#include <stdlib.h>

#include <dmalloc.h>

#include <darray.h>

darray *
darray_create(unsigned long long n, size_t size)
{
    darray *a;

    a = dalloc(sizeof(*a));
    if (a == NULL) {
        return NULL;
    }

    a->elem = dalloc(n * size);
    if (a->elem == NULL) {
        dfree(a);
        return NULL;
    }

    a->nelem = 0;
    a->size = size;
    a->nalloc = n;

    return a;
}

void
darray_destroy(darray *a)
{
    darray_deinit(a);
    dfree(a);
}

int
darray_init(darray *a, unsigned long long n, size_t size)
{
    a->elem = dalloc(n * size);
    if (a->elem == NULL) {
        return -1;
    }

    a->nelem = 0;
    a->size = size;
    a->nalloc = n;

    return 0;
}

void
darray_deinit(darray *a)
{
    if (a->elem != NULL) {
        dfree(a->elem);
    }
}

unsigned long long
darray_idx(darray *a, void *elem)
{
    char *p, *q;
    unsigned long long off, idx;

    p = a->elem;
    q = elem;
    off = (unsigned long long)(q - p);

    idx = off / (unsigned long long)a->size;

    return idx;
}

void *
darray_push(darray *a)
{
    void *elem, *new;
    size_t size;

    if (a->nelem == a->nalloc) {

        /* the array is full; allocate new array */
        size = a->size * a->nalloc;
        new = drealloc(a->elem, 2 * size);
        if (new == NULL) {
            return NULL;
        }

        a->elem = new;
        a->nalloc *= 2;
    }

    elem = (char *)a->elem + a->size * a->nelem;
    a->nelem++;

    return elem;
}

void *
darray_pop(darray *a)
{
    void *elem;

    a->nelem--;
    elem = (char *)a->elem + a->size * a->nelem;

    return elem;
}

void *
darray_get(darray *a, unsigned long long idx)
{
    void *elem;

    elem = (char *)a->elem + (a->size * idx);

    return elem;
}

void *
darray_top(darray *a)
{
    return darray_get(a, a->nelem - 1);
}

void
darray_swap(darray *a, darray *b)
{
    darray tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
}

/*
 * Sort nelem elements of the array in ascending order based on the
 * compare comparator.
 */
void
darray_sort(darray *a, darray_compare_t compare)
{
    qsort(a->elem, a->nelem, a->size, compare);
}

/*
 * Calls the func once for each element in the array as long as func returns
 * success. On failure short-circuits and returns the error status.
 */
int
darray_each(darray *a, darray_each_t func, void *data)
{
    unsigned long long i, nelem;

    for (i = 0, nelem = darray_n(a); i < nelem; i++) {
        void *elem = darray_get(a, i);
        int ret;

        ret = func(elem, data);
        if (ret != 0) {
            return -1;
        }
    }

    return 0;
}


================================================
FILE: dep/darray/darray.h
================================================
#ifndef _DARRAY_H_
#define _DARRAY_H_

typedef int (*darray_compare_t)(const void *, const void *);
typedef int (*darray_each_t)(void *, void *);

typedef struct darray {
    unsigned long long   nelem;  /* # element */
    void                 *elem;  /* element */
    size_t               size;   /* element size */
    unsigned long long   nalloc; /* # allocated element */
} darray;

#define null_darray { 0, NULL, 0, 0 }

static inline void
darray_null(darray *a)
{
    a->nelem = 0;
    a->elem = NULL;
    a->size = 0;
    a->nalloc = 0;
}

static inline void
darray_set(darray *a, void *elem, size_t size, unsigned long long nalloc)
{
    a->nelem = 0;
    a->elem = elem;
    a->size = size;
    a->nalloc = nalloc;
}

static inline unsigned long long
darray_n(const darray *a)
{
    return a->nelem;
}

darray *darray_create(unsigned long long n, size_t size);
void darray_destroy(darray *a);
int darray_init(darray *a, unsigned long long n, size_t size);
void darray_deinit(darray *a);

unsigned long long darray_idx(darray *a, void *elem);
void *darray_push(darray *a);
void *darray_pop(darray *a);
void *darray_get(darray *a, unsigned long long idx);
void *darray_top(darray *a);
void darray_swap(darray *a, darray *b);
void darray_sort(darray *a, darray_compare_t compare);
int darray_each(darray *a, darray_each_t func, void *data);

#endif


================================================
FILE: dep/dhashkit/Makefile.am
================================================
MAINTAINERCLEANFILES = Makefile.in

AM_CFLAGS = -Wall -Wshadow
AM_CFLAGS += -Wno-unused-parameter -Wno-unused-value

noinst_LIBRARIES = libdhashkit.a

noinst_HEADERS = dhashkit.h

libdhashkit_a_SOURCES =	\
	dhashkit.h		    \
	dcrc16.c			\
	dcrc32.c			\
	dfnv.c			    \
	dhsieh.c			\
	djenkins.c		    \
	dketama.c			\
	dmd5.c			    \
	dmodula.c			\
	dmurmur.c			\
	done_at_a_time.c	\
	drandom.c			\
	dsha1.c

================================================
FILE: dep/dhashkit/dcrc16.c
================================================
#include <dhashkit.h>

static const uint16_t crc16tab[256] = {
  0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
  0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
  0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
  0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
  0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
  0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
  0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
  0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
  0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
  0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
  0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
  0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
  0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
  0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
  0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
  0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
  0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
  0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
  0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
  0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
  0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
  0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
  0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
  0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
  0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
  0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
  0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
  0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
  0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
  0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
  0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
  0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,
};

uint32_t
hash_crc16(const char *key, size_t key_length)
{
    uint64_t x;
    uint32_t crc = 0;

    for (x=0; x < key_length; x++) {
        crc = (crc << 8) ^ crc16tab[((crc >> 8) ^ *key++) & 0x00ff];
    }

    return crc;
}


================================================
FILE: dep/dhashkit/dcrc32.c
================================================
#include <dhashkit.h>

static const uint32_t crc32tab[256] = {
    0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
    0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
    0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
    0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
    0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
    0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
    0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
    0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
    0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
    0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
    0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
    0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
    0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
    0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
    0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
    0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
    0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
    0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
    0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
    0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
    0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
    0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
    0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
    0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
    0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
    0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
    0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
    0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
    0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
    0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
    0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
    0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
    0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
    0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
    0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
    0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
    0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
    0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
    0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
    0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
    0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
    0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
    0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
    0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
    0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
    0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
    0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
    0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
    0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
    0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
    0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
    0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
    0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
    0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
    0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
    0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
    0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
    0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
    0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
    0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
    0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
    0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
    0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
    0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
};

/*
 * CRC-32 implementation compatible with libmemcached library. Unfortunately
 * this implementation does not return CRC-32 as per spec.
 */
uint32_t
hash_crc32(const char *key, size_t key_length)
{
    uint64_t x;
    uint32_t crc = UINT32_MAX;

    for (x = 0; x < key_length; x++) {
        crc = (crc >> 8) ^ crc32tab[(crc ^ (uint64_t)key[x]) & 0xff];
    }

    return ((~crc) >> 16) & 0x7fff;
}

uint32_t
hash_crc32a(const char *key, size_t key_length)
{
    const uint8_t *p = key;
    uint32_t crc;

    crc = ~0U;
    while (key_length--) {
        crc = crc32tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
    }

    return crc ^ ~0U;
}


================================================
FILE: dep/dhashkit/dfnv.c
================================================
#include <dhashkit.h>

static uint64_t FNV_64_INIT = UINT64_C(0xcbf29ce484222325);
static uint64_t FNV_64_PRIME = UINT64_C(0x100000001b3);
static uint32_t FNV_32_INIT = 2166136261UL;
static uint32_t FNV_32_PRIME = 16777619;

uint32_t
hash_fnv1_64(const char *key, size_t key_length)
{
    uint64_t hash = FNV_64_INIT;
    size_t x;

    for (x = 0; x < key_length; x++) {
      hash *= FNV_64_PRIME;
      hash ^= (uint64_t)key[x];
    }

    return (uint32_t)hash;
}

uint32_t
hash_fnv1a_64(const char *key, size_t key_length)
{
    uint32_t hash = (uint32_t) FNV_64_INIT;
    size_t x;

    for (x = 0; x < key_length; x++) {
      uint32_t val = (uint32_t)key[x];
      hash ^= val;
      hash *= (uint32_t) FNV_64_PRIME;
    }

    return hash;
}

uint32_t
hash_fnv1_32(const char *key, size_t key_length)
{
    uint32_t hash = FNV_32_INIT;
    size_t x;

    for (x = 0; x < key_length; x++) {
      uint32_t val = (uint32_t)key[x];
      hash *= FNV_32_PRIME;
      hash ^= val;
    }

    return hash;
}

uint32_t
hash_fnv1a_32(const char *key, size_t key_length)
{
    uint32_t hash = FNV_32_INIT;
    size_t x;

    for (x= 0; x < key_length; x++) {
      uint32_t val = (uint32_t)key[x];
      hash ^= val;
      hash *= FNV_32_PRIME;
    }

    return hash;
}


================================================
FILE: dep/dhashkit/dhashkit.h
================================================
#ifndef _DHASHKIT_H_
#define _DHASHKIT_H_

#include <stdint.h>
#include <stdio.h>

#include <sys/types.h>

struct continuum {
    uint32_t index;  /* server index */
    uint32_t value;  /* hash value */
};

#define HASH_CODEC(ACTION)                      \
    ACTION( HASH_ONE_AT_A_TIME, one_at_a_time ) \
    ACTION( HASH_MD5,           md5           ) \
    ACTION( HASH_CRC16,         crc16         ) \
    ACTION( HASH_CRC32,         crc32         ) \
    ACTION( HASH_CRC32A,        crc32a        ) \
    ACTION( HASH_FNV1_64,       fnv1_64       ) \
    ACTION( HASH_FNV1A_64,      fnv1a_64      ) \
    ACTION( HASH_FNV1_32,       fnv1_32       ) \
    ACTION( HASH_FNV1A_32,      fnv1a_32      ) \
    ACTION( HASH_HSIEH,         hsieh         ) \
    ACTION( HASH_MURMUR,        murmur        ) \
    ACTION( HASH_JENKINS,       jenkins       ) \

#define DIST_CODEC(ACTION)                      \
    ACTION( DIST_KETAMA,        ketama        ) \
    ACTION( DIST_MODULA,        modula        ) \
    ACTION( DIST_RANDOM,        random        ) \

#define DEFINE_ACTION(_hash, _name) _hash,
typedef enum hash_type {
    HASH_CODEC( DEFINE_ACTION )
    HASH_SENTINEL
} hash_type_t;
#undef DEFINE_ACTION

#define DEFINE_ACTION(_dist, _name) _dist,
typedef enum dist_type {
    DIST_CODEC( DEFINE_ACTION )
    DIST_SENTINEL
} dist_type_t;
#undef DEFINE_ACTION

uint32_t hash_one_at_a_time(const char *key, size_t key_length);
void md5_signature(const unsigned char *key, unsigned long length, unsigned char *result);
uint32_t hash_md5(const char *key, size_t key_length);
uint32_t hash_crc16(const char *key, size_t key_length);
uint32_t hash_crc32(const char *key, size_t key_length);
uint32_t hash_crc32a(const char *key, size_t key_length);
uint32_t hash_fnv1_64(const char *key, size_t key_length);
uint32_t hash_fnv1a_64(const char *key, size_t key_length);
uint32_t hash_fnv1_32(const char *key, size_t key_length);
uint32_t hash_fnv1a_32(const char *key, size_t key_length);
uint32_t hash_hsieh(const char *key, size_t key_length);
uint32_t hash_jenkins(const char *key, size_t length);
uint32_t hash_murmur(const char *key, size_t length);

uint32_t ketama_dispatch(struct continuum *continuum, uint32_t ncontinuum, uint32_t hash);
uint32_t modula_dispatch(struct continuum *continuum, uint32_t ncontinuum, uint32_t hash);
uint32_t random_dispatch(struct continuum *continuum, uint32_t ncontinuum, uint32_t hash);


/*SHA-1 in CBy Steve Reid <steve@edmweb.com>100% Public Domain*/
typedef struct {
    uint32_t state[5];    
    uint32_t count[2];    
    unsigned char buffer[64];
} SHA1_CTX;

void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
void SHA1Init(SHA1_CTX* context);
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);

#endif


================================================
FILE: dep/dhashkit/dhsieh.c
================================================
#include <dhashkit.h>

#undef get16bits
#if (defined(__GNUC__) && defined(__i386__))
#define get16bits(d) (*((const uint16_t *) (d)))
#endif

#if !defined (get16bits)
#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
                      +(uint32_t)(((const uint8_t *)(d))[0]) )
#endif

uint32_t
hash_hsieh(const char *key, size_t key_length)
{
    uint32_t hash = 0, tmp;
    int rem;

    if (key_length <= 0 || key == NULL) {
        return 0;
    }

    rem = key_length & 3;
    key_length >>= 2;

    /* Main loop */
    for (;key_length > 0; key_length--) {
        hash += get16bits (key);
        tmp = (get16bits (key+2) << 11) ^ hash;
        hash = (hash << 16) ^ tmp;
        key += 2*sizeof (uint16_t);
        hash += hash >> 11;
    }

    /* Handle end cases */
    switch (rem) {
    case 3:
        hash += get16bits (key);
        hash ^= hash << 16;
        hash ^= (uint32_t)key[sizeof (uint16_t)] << 18;
        hash += hash >> 11;
        break;

    case 2:
        hash += get16bits (key);
        hash ^= hash << 11;
        hash += hash >> 17;
        break;

    case 1:
        hash += (unsigned char)(*key);
        hash ^= hash << 10;
        hash += hash >> 1;

    default:
        break;
    }

    /* Force "avalanching" of final 127 bits */
    hash ^= hash << 3;
    hash += hash >> 5;
    hash ^= hash << 4;
    hash += hash >> 17;
    hash ^= hash << 25;
    hash += hash >> 6;

    return hash;
}


================================================
FILE: dep/dhashkit/djenkins.c
================================================
#include <dhashkit.h>

#define hashsize(n) ((uint32_t)1<<(n))
#define hashmask(n) (hashsize(n)-1)
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))

#define mix(a,b,c) \
{ \
  a -= c;  a ^= rot(c, 4);  c += b; \
  b -= a;  b ^= rot(a, 6);  a += c; \
  c -= b;  c ^= rot(b, 8);  b += a; \
  a -= c;  a ^= rot(c,16);  c += b; \
  b -= a;  b ^= rot(a,19);  a += c; \
  c -= b;  c ^= rot(b, 4);  b += a; \
}

#define final(a,b,c) \
{ \
  c ^= b; c -= rot(b,14); \
  a ^= c; a -= rot(c,11); \
  b ^= a; b -= rot(a,25); \
  c ^= b; c -= rot(b,16); \
  a ^= c; a -= rot(c,4);  \
  b ^= a; b -= rot(a,14); \
  c ^= b; c -= rot(b,24); \
}

#define JENKINS_INITVAL 13

/*
 * jenkins_hash() -- hash a variable-length key into a 32-bit value
 *  k       : the key (the unaligned variable-length array of bytes)
 *  length  : the length of the key, counting by bytes
 *  initval : can be any 4-byte value
 * Returns a 32-bit value.  Every bit of the key affects every bit of
 * the return value.  Two keys differing by one or two bits will have
 * totally different hash values.

 * The best hash table sizes are powers of 2.  There is no need to do
 * mod a prime (mod is sooo slow!).  If you need less than 32 bits,
 * use a bitmask.  For example, if you need only 10 bits, do
 *   h = (h & hashmask(10));
 * In which case, the hash table should have hashsize(10) elements.
 */

uint32_t
hash_jenkins(const char *key, size_t length)
{
  uint32_t a,b,c;                                          /* internal state */
  union { const void *ptr; size_t i; } u;     /* needed for Mac Powerbook G4 */

  /* Set up the internal state */
  a = b = c = 0xdeadbeef + ((uint32_t)length) + JENKINS_INITVAL;

  u.ptr = key;
#ifndef WORDS_BIGENDIAN
  if ((u.i & 0x3) == 0)
  {
    const uint32_t *k = (const uint32_t *)key;         /* read 32-bit chunks */

    /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
    while (length > 12)
    {
      a += k[0];
      b += k[1];
      c += k[2];
      mix(a,b,c);
      length -= 12;
      k += 3;
    }

    /*----------------------------- handle the last (probably partial) block */
    /*
     * "k[2]&0xffffff" actually reads beyond the end of the string, but
     * then masks off the part it's not allowed to read.  Because the
     * string is aligned, the masked-off tail is in the same word as the
     * rest of the string.  Every machine with memory protection I've seen
     * does it on word boundaries, so is OK with this.  But VALGRIND will
     * still catch it and complain.  The masking trick does make the hash
     * noticeably faster for short strings (like English words).
     */
    switch(length)
    {
    case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
    case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break;
    case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break;
    case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break;
    case 8 : b+=k[1]; a+=k[0]; break;
    case 7 : b+=k[1]&0xffffff; a+=k[0]; break;
    case 6 : b+=k[1]&0xffff; a+=k[0]; break;
    case 5 : b+=k[1]&0xff; a+=k[0]; break;
    case 4 : a+=k[0]; break;
    case 3 : a+=k[0]&0xffffff; break;
    case 2 : a+=k[0]&0xffff; break;
    case 1 : a+=k[0]&0xff; break;
    case 0 : return c;              /* zero length strings require no mixing */
    default: return c;
    }

  }
  else if ((u.i & 0x1) == 0)
  {
    const uint16_t *k = (const uint16_t *)key;         /* read 16-bit chunks */
    const uint8_t  *k8;

    /*--------------- all but last block: aligned reads and different mixing */
    while (length > 12)
    {
      a += k[0] + (((uint32_t)k[1])<<16);
      b += k[2] + (((uint32_t)k[3])<<16);
      c += k[4] + (((uint32_t)k[5])<<16);
      mix(a,b,c);
      length -= 12;
      k += 6;
    }

    /*----------------------------- handle the last (probably partial) block */
    k8 = (const uint8_t *)k;
    switch(length)
    {
    case 12: c+=k[4]+(((uint32_t)k[5])<<16);
             b+=k[2]+(((uint32_t)k[3])<<16);
             a+=k[0]+(((uint32_t)k[1])<<16);
             break;
    case 11: c+=((uint32_t)k8[10])<<16;     /* fall through */
    case 10: c+=k[4];
             b+=k[2]+(((uint32_t)k[3])<<16);
             a+=k[0]+(((uint32_t)k[1])<<16);
             break;
    case 9 : c+=k8[8];                      /* fall through */
    case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
             a+=k[0]+(((uint32_t)k[1])<<16);
             break;
    case 7 : b+=((uint32_t)k8[6])<<16;      /* fall through */
    case 6 : b+=k[2];
             a+=k[0]+(((uint32_t)k[1])<<16);
             break;
    case 5 : b+=k8[4];                      /* fall through */
    case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
             break;
    case 3 : a+=((uint32_t)k8[2])<<16;      /* fall through */
    case 2 : a+=k[0];
             break;
    case 1 : a+=k8[0];
             break;
    case 0 : return c;                     /* zero length requires no mixing */
    default: return c;
    }

  }
  else
  {                        /* need to read the key one byte at a time */
#endif /* little endian */
    const uint8_t *k = (const uint8_t *)key;

    /*--------------- all but the last block: affect some 32 bits of (a,b,c) */
    while (length > 12)
    {
      a += k[0];
      a += ((uint32_t)k[1])<<8;
      a += ((uint32_t)k[2])<<16;
      a += ((uint32_t)k[3])<<24;
      b += k[4];
      b += ((uint32_t)k[5])<<8;
      b += ((uint32_t)k[6])<<16;
      b += ((uint32_t)k[7])<<24;
      c += k[8];
      c += ((uint32_t)k[9])<<8;
      c += ((uint32_t)k[10])<<16;
      c += ((uint32_t)k[11])<<24;
      mix(a,b,c);
      length -= 12;
      k += 12;
    }

    /*-------------------------------- last block: affect all 32 bits of (c) */
    switch(length)                   /* all the case statements fall through */
    {
    case 12: c+=((uint32_t)k[11])<<24;
    case 11: c+=((uint32_t)k[10])<<16;
    case 10: c+=((uint32_t)k[9])<<8;
    case 9 : c+=k[8];
    case 8 : b+=((uint32_t)k[7])<<24;
    case 7 : b+=((uint32_t)k[6])<<16;
    case 6 : b+=((uint32_t)k[5])<<8;
    case 5 : b+=k[4];
    case 4 : a+=((uint32_t)k[3])<<24;
    case 3 : a+=((uint32_t)k[2])<<16;
    case 2 : a+=((uint32_t)k[1])<<8;
    case 1 : a+=k[0];
             break;
    case 0 : return c;
    default : return c;
    }
#ifndef WORDS_BIGENDIAN
  }
#endif

  final(a,b,c);
  return c;
}


================================================
FILE: dep/dhashkit/dketama.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <dhashkit.h>

#define KETAMA_CONTINUUM_ADDITION   10  /* # extra slots to build into continuum */
#define KETAMA_POINTS_PER_SERVER    160 /* 40 points per hash */
#define KETAMA_MAX_HOSTLEN          86

static uint32_t
ketama_hash(const char *key, size_t key_length, uint32_t alignment)
{
    unsigned char results[16];

    md5_signature((const unsigned char*)key, (unsigned long)key_length, results);

    return ((uint32_t) (results[3 + alignment * 4] & 0xFF) << 24)
        | ((uint32_t) (results[2 + alignment * 4] & 0xFF) << 16)
        | ((uint32_t) (results[1 + alignment * 4] & 0xFF) << 8)
        | (results[0 + alignment * 4] & 0xFF);
}

static int
ketama_item_cmp(const void *t1, const void *t2)
{
    const struct continuum *ct1 = t1, *ct2 = t2;

    if (ct1->value == ct2->value) {
        return 0;
    } else if (ct1->value > ct2->value) {
        return 1;
    } else {
        return -1;
    }
}

uint32_t
ketama_dispatch(struct continuum *continuum, uint32_t ncontinuum, uint32_t hash)
{
    struct continuum *begin, *end, *left, *right, *middle;

    ASSERT(continuum != NULL);
    ASSERT(ncontinuum != 0);

    begin = left = continuum;
    end = right = continuum + ncontinuum;

    while (left < right) {
        middle = left + (right - left) / 2;
        if (middle->value < hash) {
          left = middle + 1;
        } else {
          right = middle;
        }
    }

    if (right == end) {
        right = begin;
    }

    return right->index;
}


================================================
FILE: dep/dhashkit/dmd5.c
================================================
#include <string.h>

#include <dhashkit.h>

/*
 * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
 * MD5 Message-Digest Algorithm (RFC 1321).
 *
 * Homepage: http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
 *
 * Author: Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
 */

typedef unsigned int MD5_u32plus;

typedef struct {
    MD5_u32plus lo, hi;
    MD5_u32plus a, b, c, d;
    unsigned char buffer[64];
    MD5_u32plus block[16];
} MD5_CTX;

/*
 * The basic MD5 functions.
 *
 * F and G are optimized compared to their RFC 1321 definitions for
 * architectures that lack an AND-NOT instruction, just like in Colin Plumb's
 * implementation.
 */
#define F(x, y, z)			((z) ^ ((x) & ((y) ^ (z))))
#define G(x, y, z)			((y) ^ ((z) & ((x) ^ (y))))
#define H(x, y, z)			((x) ^ (y) ^ (z))
#define I(x, y, z)			((y) ^ ((x) | ~(z)))

/*
 * The MD5 transformation for all four rounds.
 */
#define STEP(f, a, b, c, d, x, t, s)                            \
	(a) += f((b), (c), (d)) + (x) + (t);                        \
	(a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s))));  \
	(a) += (b);

/*
 * SET reads 4 input bytes in little-endian byte order and stores them
 * in a properly aligned word in host byte order.
 *
 * The check for little-endian architectures that tolerate unaligned
 * memory accesses is just an optimization.  Nothing will break if it
 * doesn't work.
 */
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
#define SET(n) \
    (*(MD5_u32plus *)&ptr[(n) * 4])
#define GET(n) \
    SET(n)
#else
#define SET(n)                                  \
    (ctx->block[(n)] =                          \
    (MD5_u32plus)ptr[(n) * 4] |                 \
    ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) |      \
    ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) |     \
    ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
#define GET(n) \
    (ctx->block[(n)])
#endif

/*
 * This processes one or more 64-byte data blocks, but does NOT update
 * the bit counters.  There are no alignment requirements.
 */
static void *
body(MD5_CTX *ctx, void *data, unsigned long size)
{
    unsigned char *ptr;
    MD5_u32plus a, b, c, d;
    MD5_u32plus saved_a, saved_b, saved_c, saved_d;

    ptr = data;

    a = ctx->a;
    b = ctx->b;
    c = ctx->c;
    d = ctx->d;

	do {
        saved_a = a;
        saved_b = b;
        saved_c = c;
        saved_d = d;

        /* Round 1 */
        STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)
        STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
        STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
        STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
        STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
        STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
        STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
        STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
        STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
        STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
        STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
        STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
        STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
        STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
        STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
        STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)

        /* Round 2 */
        STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
        STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
        STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
        STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
        STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
        STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
        STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
        STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
        STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
        STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
        STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
        STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
        STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
        STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
        STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
        STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)

        /* Round 3 */
        STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
        STEP(H, d, a, b, c, GET(8), 0x8771f681, 11)
        STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
        STEP(H, b, c, d, a, GET(14), 0xfde5380c, 23)
        STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
        STEP(H, d, a, b, c, GET(4), 0x4bdecfa9, 11)
        STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
        STEP(H, b, c, d, a, GET(10), 0xbebfbc70, 23)
        STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
        STEP(H, d, a, b, c, GET(0), 0xeaa127fa, 11)
        STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
        STEP(H, b, c, d, a, GET(6), 0x04881d05, 23)
        STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
        STEP(H, d, a, b, c, GET(12), 0xe6db99e5, 11)
        STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
        STEP(H, b, c, d, a, GET(2), 0xc4ac5665, 23)

        /* Round 4 */
        STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
        STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
        STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
        STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
        STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
        STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
        STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
        STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
        STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
        STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
        STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
        STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
        STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
        STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
        STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
        STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)

        a += saved_a;
        b += saved_b;
        c += saved_c;
        d += saved_d;

        ptr += 64;
    } while (size -= 64);

    ctx->a = a;
    ctx->b = b;
    ctx->c = c;
    ctx->d = d;

    return ptr;
}

void
MD5_Init(MD5_CTX *ctx)
{
    ctx->a = 0x67452301;
    ctx->b = 0xefcdab89;
    ctx->c = 0x98badcfe;
    ctx->d = 0x10325476;

    ctx->lo = 0;
    ctx->hi = 0;
}

void
MD5_Update(MD5_CTX *ctx, void *data, unsigned long size)
{
    MD5_u32plus saved_lo;
    unsigned long used, free;

    saved_lo = ctx->lo;
    if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) {
        ctx->hi++;
    }
    ctx->hi += size >> 29;

    used = saved_lo & 0x3f;

    if (used) {
        free = 64 - used;

        if (size < free) {
            memcpy(&ctx->buffer[used], data, size);
            return;
        }

        memcpy(&ctx->buffer[used], data, free);
        data = (unsigned char *)data + free;
        size -= free;
        body(ctx, ctx->buffer, 64);
    }

    if (size >= 64) {
        data = body(ctx, data, size & ~(unsigned long)0x3f);
        size &= 0x3f;
    }

    memcpy(ctx->buffer, data, size);
}

void
MD5_Final(unsigned char *result, MD5_CTX *ctx)
{
    unsigned long used, free;

    used = ctx->lo & 0x3f;

    ctx->buffer[used++] = 0x80;

    free = 64 - used;

    if (free < 8) {
        memset(&ctx->buffer[used], 0, free);
        body(ctx, ctx->buffer, 64);
        used = 0;
        free = 64;
    }

    memset(&ctx->buffer[used], 0, free - 8);

    ctx->lo <<= 3;
    ctx->buffer[56] = ctx->lo;
    ctx->buffer[57] = ctx->lo >> 8;
    ctx->buffer[58] = ctx->lo >> 16;
    ctx->buffer[59] = ctx->lo >> 24;
    ctx->buffer[60] = ctx->hi;
    ctx->buffer[61] = ctx->hi >> 8;
    ctx->buffer[62] = ctx->hi >> 16;
    ctx->buffer[63] = ctx->hi >> 24;

    body(ctx, ctx->buffer, 64);

    result[0] = ctx->a;
    result[1] = ctx->a >> 8;
    result[2] = ctx->a >> 16;
    result[3] = ctx->a >> 24;
    result[4] = ctx->b;
    result[5] = ctx->b >> 8;
    result[6] = ctx->b >> 16;
    result[7] = ctx->b >> 24;
    result[8] = ctx->c;
    result[9] = ctx->c >> 8;
    result[10] = ctx->c >> 16;
    result[11] = ctx->c >> 24;
    result[12] = ctx->d;
    result[13] = ctx->d >> 8;
    result[14] = ctx->d >> 16;
    result[15] = ctx->d >> 24;

    memset(ctx, 0, sizeof(*ctx));
}

/*
 * Just a simple method for getting the signature
 * result must be == 16
 */
void
md5_signature(const unsigned char *key, unsigned long length, unsigned char *result)
{
    MD5_CTX my_md5;

    MD5_Init(&my_md5);
    (void)MD5_Update(&my_md5, key, length);
    MD5_Final(result, &my_md5);
}

uint32_t
hash_md5(const char *key, size_t key_length)
{
    unsigned char results[16];

    md5_signature((const unsigned char*)key, (unsigned long)key_length, results);

    return ((uint32_t) (results[3] & 0xFF) << 24) |
           ((uint32_t) (results[2] & 0xFF) << 16) |
           ((uint32_t) (results[1] & 0xFF) << 8) |
           (results[0] & 0xFF);
}


================================================
FILE: dep/dhashkit/dmodula.c
================================================
#include <stdio.h>
#include <stdlib.h>

#include <dhashkit.h>

#define MODULA_CONTINUUM_ADDITION   10  /* # extra slots to build into continuum */
#define MODULA_POINTS_PER_SERVER    1

uint32_t
modula_dispatch(struct continuum *continuum, uint32_t ncontinuum, uint32_t hash)
{
    struct continuum *c;

    ASSERT(continuum != NULL);
    ASSERT(ncontinuum != 0);

    c = continuum + hash % ncontinuum;

    return c->index;
}


================================================
FILE: dep/dhashkit/dmurmur.c
================================================
/*
 * "Murmur" hash provided by Austin, tanjent@gmail.com
 * http://murmurhash.googlepages.com/
 *
 * Note - This code makes a few assumptions about how your machine behaves -
 *
 * 1. We can read a 4-byte value from any address without crashing
 * 2. sizeof(int) == 4
 *
 * And it has a few limitations -
 * 1. It will not work incrementally.
 * 2. It will not produce the same results on little-endian and big-endian
 *  machines.
 *
 *  Updated to murmur2 hash - BP
 */

#include <dhashkit.h>

uint32_t
hash_murmur(const char *key, size_t length)
{
    /*
     * 'm' and 'r' are mixing constants generated offline.  They're not
     * really 'magic', they just happen to work well.
     */

    const unsigned int m = 0x5bd1e995;
    const uint32_t seed = (0xdeadbeef * (uint32_t)length);
    const int r = 24;


    /* Initialize the hash to a 'random' value */

    uint32_t h = seed ^ (uint32_t)length;

    /* Mix 4 bytes at a time into the hash */

    const unsigned char * data = (const unsigned char *)key;

    while (length >= 4) {
        unsigned int k = *(unsigned int *)data;

        k *= m;
        k ^= k >> r;
        k *= m;

        h *= m;
        h ^= k;

        data += 4;
        length -= 4;
    }

    /* Handle the last few bytes of the input array */

    switch(length) {
    case 3:
        h ^= ((uint32_t)data[2]) << 16;

    case 2:
        h ^= ((uint32_t)data[1]) << 8;

    case 1:
        h ^= data[0];
        h *= m;

    default:
        break;
    };

    /*
     * Do a few final mixes of the hash to ensure the last few bytes are
     * well-incorporated.
     */

    h ^= h >> 13;
    h *= m;
    h ^= h >> 15;

    return h;
}


================================================
FILE: dep/dhashkit/done_at_a_time.c
================================================
/*
 * HashKit
 * Copyright (C) 2009 Brian Aker
 * All rights reserved.
 *
 * Use and distribution licensed under the BSD license.  See
 * the COPYING file in the parent directory for full text.
 */

/*
 * This has is Jenkin's "One at A time Hash".
 * http://en.wikipedia.org/wiki/Jenkins_hash_function
 */

#include <dhashkit.h>

uint32_t
hash_one_at_a_time(const char *key, size_t key_length)
{
    const char *ptr = key;
    uint32_t value = 0;

    while (key_length--) {
        uint32_t val = (uint32_t) *ptr++;
        value += val;
        value += (value << 10);
        value ^= (value >> 6);
    }
    value += (value << 3);
    value ^= (value >> 11);
    value += (value << 15);

    return value;
}


================================================
FILE: dep/dhashkit/drandom.c
================================================
#include <stdio.h>
#include <stdlib.h>

#include <dhashkit.h>

#define RANDOM_CONTINUUM_ADDITION   10  /* # extra slots to build into continuum */
#define RANDOM_POINTS_PER_SERVER    1

uint32_t
random_dispatch(struct continuum *continuum, uint32_t ncontinuum, uint32_t hash)
{
    struct continuum *c;

    ASSERT(continuum != NULL);
    ASSERT(ncontinuum != 0);

    c = continuum + random() % ncontinuum;

    return c->index;
}


================================================
FILE: dep/dhashkit/dsha1.c
================================================

/* from valgrind tests */

/* ================ sha1.c ================ */
/*
SHA-1 in C
By Steve Reid <steve@edmweb.com>
100% Public Domain

Test Vectors (from FIPS PUB 180-1)
"abc"
  A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
  84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
A million repetitions of "a"
  34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/

/* #define LITTLE_ENDIAN * This should be #define'd already, if true. */
/* #define SHA1HANDSOFF * Copies data before messing with it. */

#define SHA1HANDSOFF

#include <stdio.h>
#include <string.h>
#include <stdint.h>

#include <dhashkit.h>

#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))

/* blk0() and blk() perform the initial expand. */
/* I got the idea of expanding during the round function from SSLeay */
#ifdef VR_LITTLE_ENDIAN
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
    |(rol(block->l[i],8)&0x00FF00FF))
#else
#define blk0(i) block->l[i]
#endif
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
    ^block->l[(i+2)&15]^block->l[i&15],1))

/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);


/* Hash a single 512-bit block. This is the core of the algorithm. */

void SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
{
    uint32_t a, b, c, d, e;
    typedef union {
        unsigned char c[64];
        uint32_t l[16];
    } CHAR64LONG16;
#ifdef SHA1HANDSOFF
    CHAR64LONG16 block[1];  /* use array to appear as a pointer */
    memcpy(block, buffer, 64);
#else
    /* The following had better never be used because it causes the
     * pointer-to-const buffer to be cast into a pointer to non-const.
     * And the result is written through.  I threw a "const" in, hoping
     * this will cause a diagnostic.
     */
    CHAR64LONG16* block = (const CHAR64LONG16*)buffer;
#endif
    /* Copy context->state[] to working vars */
    a = state[0];
    b = state[1];
    c = state[2];
    d = state[3];
    e = state[4];
    /* 4 rounds of 20 operations each. Loop unrolled. */
    R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
    R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
    R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
    R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
    R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
    R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
    R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
    R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
    R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
    R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
    R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
    R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
    R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
    R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
    R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
    R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
    R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
    R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
    R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
    R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
    /* Add the working vars back into context.state[] */
    state[0] += a;
    state[1] += b;
    state[2] += c;
    state[3] += d;
    state[4] += e;
    /* Wipe variables */
    a = b = c = d = e = 0;
#ifdef SHA1HANDSOFF
    memset(block, '\0', sizeof(block));
#endif
}


/* SHA1Init - Initialize new context */

void SHA1Init(SHA1_CTX* context)
{
    /* SHA1 initialization constants */
    context->state[0] = 0x67452301;
    context->state[1] = 0xEFCDAB89;
    context->state[2] = 0x98BADCFE;
    context->state[3] = 0x10325476;
    context->state[4] = 0xC3D2E1F0;
    context->count[0] = context->count[1] = 0;
}


/* Run your data through this. */

void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len)
{
    uint32_t i, j;

    j = context->count[0];
    if ((context->count[0] += len << 3) < j)
        context->count[1]++;
    context->count[1] += (len>>29);
    j = (j >> 3) & 63;
    if ((j + len) > 63) {
        memcpy(&context->buffer[j], data, (i = 64-j));
        SHA1Transform(context->state, context->buffer);
        for ( ; i + 63 < len; i += 64) {
            SHA1Transform(context->state, &data[i]);
        }
        j = 0;
    }
    else i = 0;
    memcpy(&context->buffer[j], &data[i], len - i);
}


/* Add padding and return the message digest. */

void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
{
    unsigned i;
    unsigned char finalcount[8];
    unsigned char c;

#if 0	/* untested "improvement" by DHR */
    /* Convert context->count to a sequence of bytes
     * in finalcount.  Second element first, but
     * big-endian order within element.
     * But we do it all backwards.
     */
    unsigned char *fcp = &finalcount[8];

    for (i = 0; i < 2; i++)
       {
        uint32_t t = context->count[i];
        int j;

        for (j = 0; j < 4; t >>= 8, j++)
	          *--fcp = (unsigned char) t;
    }
#else
    for (i = 0; i < 8; i++) {
        finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
         >> ((3-(i & 3)) * 8) ) & 255);  /* Endian independent */
    }
#endif
    c = 0200;
    SHA1Update(context, &c, 1);
    while ((context->count[0] & 504) != 448) {
	c = 0000;
        SHA1Update(context, &c, 1);
    }
    SHA1Update(context, finalcount, 8);  /* Should cause a SHA1Transform() */
    for (i = 0; i < 20; i++) {
        digest[i] = (unsigned char)
         ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
    }
    /* Wipe variables */
    memset(context, '\0', sizeof(*context));
    memset(&finalcount, '\0', sizeof(finalcount));
}
/* ================ end of sha1.c ================ */


================================================
FILE: dep/dlist/Makefile.am
================================================
MAINTAINERCLEANFILES = Makefile.in

AM_CPPFLAGS =
if !OS_SOLARIS
AM_CPPFLAGS += -D_GNU_SOURCE
endif
AM_CPPFLAGS += -I $(top_srcdir)/dep/util
AM_CPPFLAGS += -I $(top_srcdir)/dep/jemalloc-4.2.0/include
AM_CPPFLAGS += -I $(top_srcdir)/dep/dmalloc

AM_CFLAGS = -Wall -Wshadow
AM_CFLAGS += -Wno-unused-parameter -Wno-unused-value

noinst_LIBRARIES = libdlist.a

noinst_HEADERS = dlist.h dmtqueue.h dlockqueue.h

libdlist_a_SOURCES =	            \
	dlist.c dlist.h                 \
    dmtqueue.c dmtqueue.h           \
    dlockqueue.c dlockqueue.h

================================================
FILE: dep/dlist/dlist.c
================================================
#include <stdlib.h>

#include <dmalloc.h>

#include <dlist.h>

/* Create a new list. The created list can be freed with
 * AlFreeList(), but private value of every node need to be freed
 * by the user before to call AlFreeList().
 *
 * On error, NULL is returned. Otherwise the pointer to the new list. */
dlist *dlistCreate(void)
{
    struct dlist *list;

    if ((list = dalloc(sizeof(*list))) == NULL)
        return NULL;
    list->head = list->tail = NULL;
    list->len = 0;
    list->dup = NULL;
    list->free = NULL;
    list->match = NULL;
    return list;
}

/* Free the whole list.
 *
 * This function can't fail. */
void dlistRelease(dlist *list)
{
    unsigned long len;
    dlistNode *current, *next;

    current = list->head;
    len = list->len;
    while(len--) {
        next = current->next;
        if (list->free) list->free(current->value);
        dfree(current);
        current = next;
    }
    dfree(list);
}

/* Add a new node to the list, to head, containing the specified 'value'
 * pointer as value.
 *
 * On error, NULL is returned and no operation is performed (i.e. the
 * list remains unaltered).
 * On success the 'list' pointer you pass to the function is returned. */
dlist *dlistAddNodeHead(dlist *list, void *value)
{
    dlistNode *node;

    if ((node = dalloc(sizeof(*node))) == NULL)
        return NULL;
    node->value = value;
    if (list->len == 0) {
        list->head = list->tail = node;
        node->prev = node->next = NULL;
    } else {
        node->prev = NULL;
        node->next = list->head;
        list->head->prev = node;
        list->head = node;
    }
    list->len++;
    return list;
}

/* Add a new node to the list, to tail, containing the specified 'value'
 * pointer as value.
 *
 * On error, NULL is returned and no operation is performed (i.e. the
 * list remains unaltered).
 * On success the 'list' pointer you pass to the function is returned. */
dlist *dlistAddNodeTail(dlist *list, void *value)
{
    dlistNode *node;

    if ((node = dalloc(sizeof(*node))) == NULL)
        return NULL;
    node->value = value;
    if (list->len == 0) {
        list->head = list->tail = node;
        node->prev = node->next = NULL;
    } else {
        node->prev = list->tail;
        node->next = NULL;
        list->tail->next = node;
        list->tail = node;
    }
    list->len++;
    return list;
}

dlist *dlistInsertNode(dlist *list, dlistNode *old_node, void *value, int after) {
    dlistNode *node;

    if ((node = dalloc(sizeof(*node))) == NULL)
        return NULL;
    node->value = value;
    if (after) {
        node->prev = old_node;
        node->next = old_node->next;
        if (list->tail == old_node) {
            list->tail = node;
        }
    } else {
        node->next = old_node;
        node->prev = old_node->prev;
        if (list->head == old_node) {
            list->head = node;
        }
    }
    if (node->prev != NULL) {
        node->prev->next = node;
    }
    if (node->next != NULL) {
        node->next->prev = node;
    }
    list->len++;
    return list;
}

/* Remove the specified node from the specified list.
 * It's up to the caller to free the private value of the node.
 *
 * This function can't fail. */
void dlistDelNode(dlist *list, dlistNode *node)
{
    if (node->prev)
        node->prev->next = node->next;
    else
        list->head = node->next;
    if (node->next)
        node->next->prev = node->prev;
    else
        list->tail = node->prev;
    if (list->free) list->free(node->value);
    dfree(node);
    list->len--;
}

/* Returns a list iterator 'iter'. After the initialization every
 * call to dlistNext() will return the next element of the list.
 *
 * This function can't fail. */
dlistIter *dlistGetIterator(dlist *list, int direction)
{
    dlistIter *iter;

    if ((iter = dalloc(sizeof(*iter))) == NULL) return NULL;
    if (direction == AL_START_HEAD)
        iter->next = list->head;
    else
        iter->next = list->tail;
    iter->direction = direction;
    return iter;
}

/* Release the iterator memory */
void dlistReleaseIterator(dlistIter *iter) {
    dfree(iter);
}

/* Create an iterator in the list private iterator structure */
void dlistRewind(dlist *list, dlistIter *li) {
    li->next = list->head;
    li->direction = AL_START_HEAD;
}

void dlistRewindTail(dlist *list, dlistIter *li) {
    li->next = list->tail;
    li->direction = AL_START_TAIL;
}

/* Return the next element of an iterator.
 * It's valid to remove the currently returned element using
 * dlistDelNode(), but not to remove other elements.
 *
 * The function returns a pointer to the next element of the list,
 * or NULL if there are no more elements, so the classical usage patter
 * is:
 *
 * iter = dlistGetIterator(list,<direction>);
 * while ((node = dlistNext(iter)) != NULL) {
 *     doSomethingWith(dlistNodeValue(node));
 * }
 *
 * */
dlistNode *dlistNext(dlistIter *iter)
{
    dlistNode *current = iter->next;

    if (current != NULL) {
        if (iter->direction == AL_START_HEAD)
            iter->next = current->next;
        else
            iter->next = current->prev;
    }
    return current;
}

/* Duplicate the whole list. On out of memory NULL is returned.
 * On success a copy of the original list is returned.
 *
 * The 'Dup' method set with listSetDupMethod() function is used
 * to copy the node value. Otherwise the same pointer value of
 * the original node is used as value of the copied node.
 *
 * The original list both on success or error is never modified. */
dlist *dlistDup(dlist *orig)
{
    dlist *copy;
    dlistIter iter;
    dlistNode *node;

    if ((copy = dlistCreate()) == NULL)
        return NULL;
    copy->dup = orig->dup;
    copy->free = orig->free;
    copy->match = orig->match;
    dlistRewind(orig, &iter);
    while((node = dlistNext(&iter)) != NULL) {
        void *value;

        if (copy->dup) {
            value = copy->dup(node->value);
            if (value == NULL) {
                dlistRelease(copy);
                return NULL;
            }
        } else
            value = node->value;
        if (dlistAddNodeTail(copy, value) == NULL) {
            dlistRelease(copy);
            return NULL;
        }
    }
    return copy;
}

/* Search the list for a node matching a given key.
 * The match is performed using the 'match' method
 * set with listSetMatchMethod(). If no 'match' method
 * is set, the 'value' pointer of every node is directly
 * compared with the 'key' pointer.
 *
 * On success the first matching node pointer is returned
 * (search starts from head). If no matching node exists
 * NULL is returned. */
dlistNode *dlistSearchKey(dlist *list, void *key)
{
    dlistIter iter;
    dlistNode *node;

    dlistRewind(list, &iter);
    while((node = dlistNext(&iter)) != NULL) {
        if (list->match) {
            if (list->match(node->value, key)) {
                return node;
            }
        } else {
            if (key == node->value) {
                return node;
            }
        }
    }
    return NULL;
}

/* Return the element at the specified zero-based index
 * where 0 is the head, 1 is the element next to head
 * and so on. Negative integers are used in order to count
 * from the tail, -1 is the last element, -2 the penultimate
 * and so on. If the index is out of range NULL is returned. */
dlistNode *dlistIndex(dlist *list, long index) {
    dlistNode *n;

    if (index < 0) {
        index = (-index)-1;
        n = list->tail;
        while(index-- && n) n = n->prev;
    } else {
        n = list->head;
        while(index-- && n) n = n->next;
    }
    return n;
}

/* Rotate the list removing the tail node and inserting it to the head. */
void dlistRotate(dlist *list) {
    dlistNode *tail = list->tail;

    if (dlistLength(list) <= 1) return;

    /* Detach current tail */
    list->tail = tail->prev;
    list->tail->next = NULL;
    /* Move it as head */
    list->head->prev = tail;
    tail->prev = NULL;
    tail->next = list->head;
    list->head = tail;
}

dlist *dlistPush(dlist *list, void *value) {
    dlistAddNodeTail(list, value);
    return list;
}

void *dlistPop(dlist *list) {
    dlistNode *node;
    void *value;
    
    node = dlistFirst(list);
    if (node == NULL) {
        return NULL;
    }

    value = dlistNodeValue(node);
    dlistDelNode(list, node);

    if (list->free) return NULL;
    
    return value;
}


================================================
FILE: dep/dlist/dlist.h
================================================
#ifndef _DLIST_H__
#define _DLIST_H__

/* Node, List, and Iterator are the only data structures used currently. */

typedef struct dlistNode {
    struct dlistNode *prev;
    struct dlistNode *next;
    void *value;
} dlistNode;

typedef struct dlistIter {
    dlistNode *next;
    int direction;
} dlistIter;

typedef struct dlist {
    dlistNode *head;
    dlistNode *tail;
    void *(*dup)(void *ptr);
    void (*free)(void *ptr);
    int (*match)(void *ptr, void *key);
    unsigned long len;
} dlist;

/* Functions implemented as macros */
#define dlistLength(l) ((l)->len)
#define dlistFirst(l) ((l)->head)
#define dlistLast(l) ((l)->tail)
#define dlistPrevNode(n) ((n)->prev)
#define dlistNextNode(n) ((n)->next)
#define dlistNodeValue(n) ((n)->value)

#define dlistSetDupMethod(l,m) ((l)->dup = (m))
#define dlistSetFreeMethod(l,m) ((l)->free = (m))
#define dlistSetMatchMethod(l,m) ((l)->match = (m))

#define dlistGetDupMethod(l) ((l)->dup)
#define dlistGetFree(l) ((l)->free)
#define dlistGetMatchMethod(l) ((l)->match)

/* Prototypes */
dlist *dlistCreate(void);
void dlistRelease(dlist *list);
dlist *dlistAddNodeHead(dlist *list, void *value);
dlist *dlistAddNodeTail(dlist *list, void *value);
dlist *dlistInsertNode(dlist *list, dlistNode *old_node, void *value, int after);
void dlistDelNode(dlist *list, dlistNode *node);
dlistIter *dlistGetIterator(dlist *list, int direction);
dlistNode *dlistNext(dlistIter *iter);
void dlistReleaseIterator(dlistIter *iter);
dlist *dlistDup(dlist *orig);
dlistNode *dlistSearchKey(dlist *list, void *key);
dlistNode *dlistIndex(dlist *list, long index);
void dlistRewind(dlist *list, dlistIter *li);
void dlistRewindTail(dlist *list, dlistIter *li);
void dlistRotate(dlist *list);
dlist *dlistPush(dlist *list, void *value);
void *dlistPop(dlist *list);

/* Directions for iterators */
#define AL_START_HEAD 0
#define AL_START_TAIL 1

#endif /* __ADLIST_H__ */


================================================
FILE: dep/dlist/dlockqueue.c
================================================
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

#include <dmalloc.h>

#include <dlist.h>
#include <dmtqueue.h>
#include <dlockqueue.h>

dlockqueue *dlockqueue_create(void)
{
    dlockqueue *lqueue;

    lqueue = dalloc(sizeof(*lqueue));
    if (lqueue == NULL) {
        return NULL;
    }

    lqueue->maxlen = -1;
    lqueue->maxlen_policy = MAX_LENGTH_POLICY_REJECT;
    pthread_mutex_init(&lqueue->lmutex,NULL);
    
    lqueue->l = dlistCreate();
    if (lqueue->l == NULL) {
        dlockqueue_destroy(lqueue);
        return NULL;
    }

    return lqueue;
}

long long dlockqueue_push(void *q, void *value)
{
    dlockqueue *lqueue = q;
    dlist *list;
    long long length;
    
    pthread_mutex_lock(&lqueue->lmutex);
    length = (long long)dlistLength(lqueue->l);
    if (lqueue->maxlen >0 && length >= lqueue->maxlen) {
        if (lqueue->maxlen_policy == MAX_LENGTH_POLICY_REJECT) {
            length = -1;
        } else if (lqueue->maxlen_policy == MAX_LENGTH_POLICY_EVICT_HEAD) {
            while (length >= lqueue->maxlen) {
                dlistNode *ln = dlistFirst(lqueue->l);
                dlistDelNode(lqueue->l,ln);
                length = (long long)dlistLength(lqueue->l);
            }
            list = dlistAddNodeTail(lqueue->l, value);
            length ++;
        } else if (lqueue->maxlen_policy == MAX_LENGTH_POLICY_EVICT_END) {
            while (length >= lqueue->maxlen) {
                dlistNode *ln = dlistLast(lqueue->l);
                dlistDelNode(lqueue->l,ln);
                length = (long long)dlistLength(lqueue->l);
            }
            list = dlistAddNodeTail(lqueue->l, value);
            length ++;
        }
    } else {
        list = dlistAddNodeTail(lqueue->l, value);
        length ++;
    }
    pthread_mutex_unlock(&lqueue->lmutex);

    if (list == NULL) {
        return -1;
    }

    return length;
}

void *dlockqueue_pop(void *q)
{
    dlockqueue *lqueue = q;
    dlistNode *node;
    void *value;
        
    if (lqueue == NULL || lqueue->l == NULL) {
        return NULL;
    }
    
    pthread_mutex_lock(&lqueue->lmutex);
    
    node = dlistFirst(lqueue->l);
    if (node == NULL) {
        pthread_mutex_unlock(&lqueue->lmutex);
        return NULL;
    }

    value = dlistNodeValue(node);

    dlistDelNode(lqueue->l, node);

    pthread_mutex_unlock(&lqueue->lmutex);

    return value;
}

void dlockqueue_destroy(void *q)
{
    dlockqueue *lqueue = q;
    if (lqueue == NULL) {
        return;
    }

    if (lqueue->l != NULL) {
        dlistRelease(lqueue->l);
    }

    pthread_mutex_destroy(&lqueue->lmutex);

    dfree(lqueue);
}

long long dlockqueue_length(void *q)
{
    dlockqueue *lqueue = q;
    long long length;
    
    if (lqueue == NULL || lqueue->l == NULL) {
        return -1;
    }

    pthread_mutex_lock(&lqueue->lmutex);
    length = dlistLength(lqueue->l);
    pthread_mutex_unlock(&lqueue->lmutex);
    
    return length;
}


================================================
FILE: dep/dlist/dlockqueue.h
================================================
#ifndef _DLOCKQUEUE_H_
#define _DLOCKQUEUE_H_

struct dlist;

typedef struct dlockqueue{
    struct dlist *l;
    long long maxlen;
    int maxlen_policy;
    pthread_mutex_t lmutex;
} dlockqueue;

dlockqueue *dlockqueue_create(void);
long long dlockqueue_push(void *q, void *value);
void *dlockqueue_pop(void *q);
void dlockqueue_destroy(void *q);
long long dlockqueue_length(void *q);

#endif


================================================
FILE: dep/dlist/dmtqueue.c
================================================
#include <stdlib.h>

#include <dmalloc.h>

#include <dlist.h>
#include <dmtqueue.h>
#include <dlockqueue.h>

/******** multi-thread safe queue interface ********/
dmtqueue *dmtqueue_create(void)
{
    dmtqueue *q;

    q = dalloc(sizeof(*q));
    if (q == NULL) {
        return NULL;
    }

    q->l = NULL;
    q->lock_push = NULL;
    q->lock_pop = NULL;
    q->destroy = NULL;
    q->length = NULL;
    
    return q;
}

void dmtqueue_destroy(dmtqueue *q)
{
    if (q == NULL) {
        return;
    }

    if (q->destroy) {
        q->destroy(q->l);
    }

    dfree(q);
}

long long dmtqueue_push(dmtqueue *q, void *value)
{
    if(q == NULL || q->l == NULL
        || q->lock_push == NULL)
    {
        return -1;
    }

    return q->lock_push(q->l, value);
}

void *dmtqueue_pop(dmtqueue *q)
{
    if(q == NULL || q->l == NULL
        || q->lock_pop == NULL)
    {
        return NULL;
    }
    
    return q->lock_pop(q->l);
}

int dmtqueue_empty(dmtqueue *q)
{
    if(q == NULL || q->l == NULL
        || q->length == NULL)
    {
        return -1;
    }

    if(q->length(q->l) > 0)
    {
        return 0;
    }

    return 1;
}

long long dmtqueue_length(dmtqueue *q)
{
    if(q == NULL || q->l == NULL
        || q->length == NULL)
    {
        return -1;
    }

    return q->length(q->l);
}

/******** multi-thread safe queue implement ********/

/**
* This is multi-thread safe queue.
* This lock list's performance is not good, but it is safe.
*/
int dmtqueue_init_with_lockqueue(dmtqueue *q, dlockqueue_freefunc freefunc)
{
    dlockqueue *lq;
    
    if (q == NULL) {
        return -1;
    }

    lq = dlockqueue_create();
    if (lq == NULL) {
        return -1;
    }

    lq->l->free = freefunc;

    q->l = lq;
    q->lock_push = dlockqueue_push;
    q->lock_pop = dlockqueue_pop;
    q->destroy = dlockqueue_destroy;
    q->length = dlockqueue_length;
    
    return 0;
}


================================================
FILE: dep/dlist/dmtqueue.h
================================================
#ifndef _DMTQUEUE_H_
#define _DMTQUEUE_H_

#define MAX_LENGTH_POLICY_REJECT        0
#define MAX_LENGTH_POLICY_EVICT_HEAD    1
#define MAX_LENGTH_POLICY_EVICT_END     2

/* Multi-thread safe queue */
typedef struct dmtqueue{
    void *l;
    long long (*lock_push)(void *q, void *value);
    void *(*lock_pop)(void *q);
    void (*destroy)(void *q);
    long long (*length)(void *q);
} dmtqueue;

#define dmtqueueSetMaxlength(q,l)        ((q)->l->maxlen = (l))
#define dmtqueueSetMaxlengthPolicy(q,p)  ((q)->l->maxlen = (p))

typedef int (*dmtqueue_init)(dmtqueue *);

/******** multi-thread safe list interface ********/

dmtqueue *dmtqueue_create(void);
void dmtqueue_destroy(dmtqueue *q);
long long dmtqueue_push(dmtqueue *q, void *value);
void *dmtqueue_pop(dmtqueue *q);
int dmtqueue_empty(dmtqueue *q);
long long dmtqueue_length(dmtqueue *q);

/******** multi-thread safe list implement ********/

typedef void (*dlockqueue_freefunc)(void *);
int dmtqueue_init_with_lockqueue(dmtqueue *l, dlockqueue_freefunc freefunc);

#endif


================================================
FILE: dep/dmalloc/Makefile.am
================================================
MAINTAINERCLEANFILES = Makefile.in

AM_CPPFLAGS =
if !OS_SOLARIS
AM_CPPFLAGS += -D_GNU_SOURCE
endif
AM_CPPFLAGS += -I $(top_srcdir)/dep/jemalloc-4.2.0/include
AM_CPPFLAGS += -I $(top_srcdir)/dep/util

AM_CFLAGS = -Wall -Wshadow
AM_CFLAGS += -Wno-unused-parameter -Wno-unused-value

noinst_LIBRARIES = libdmalloc.a

noinst_HEADERS = dmalloc.h

libdmalloc_a_SOURCES =      \
	dmalloc.c dmalloc.h

================================================
FILE: dep/dmalloc/dmalloc.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>

#include <unistd.h>

#include <dutil.h>
#include <dlog.h>

#include <dmalloc.h>

/*memory api*/
static size_t used_memory = 0;
pthread_mutex_t used_memory_mutex = PTHREAD_MUTEX_INITIALIZER;

#if defined(__ATOMIC_RELAXED)
#define update_used_mem_stat_add(__n) __atomic_add_fetch(&used_memory, (__n), __ATOMIC_RELAXED)
#define update_used_mem_stat_sub(__n) __atomic_sub_fetch(&used_memory, (__n), __ATOMIC_RELAXED)
char *malloc_lock_type(void) {return "__ATOMIC_RELAXED";}
#elif defined(HAVE_ATOMIC)
#define update_used_mem_stat_add(__n) __sync_add_and_fetch(&used_memory, (__n))
#define update_used_mem_stat_sub(__n) __sync_sub_and_fetch(&used_memory, (__n))
char *malloc_lock_type(void) {return "HAVE_ATOMIC";}
#else
#define update_used_mem_stat_add(__n) do {      \
    pthread_mutex_lock(&used_memory_mutex);     \
    used_memory += (__n); \
    pthread_mutex_unlock(&used_memory_mutex);   \
} while(0)

#define update_used_mem_stat_sub(__n) do {      \
    pthread_mutex_lock(&used_memory_mutex);     \
    used_memory -= (__n); \
    pthread_mutex_unlock(&used_memory_mutex);   \
} while(0)

char *malloc_lock_type(void) {return "pthread_mutex_t";}
#endif

#define update_dmalloc_stat_alloc(__n) do {                                 \
    size_t _n = (__n);                                                      \
    if (_n&(sizeof(long)-1)) _n += sizeof(long)-(_n&(sizeof(long)-1));    \
    update_used_mem_stat_add(_n);                                           \
} while(0)

#define update_dmalloc_stat_free(__n) do {                                  \
    size_t _n = (__n);                                                      \
    if (_n&(sizeof(long)-1)) _n += sizeof(long)-(_n&(sizeof(long)-1));    \
    update_used_mem_stat_sub(_n);                                           \
} while(0)

#ifdef HAVE_MALLOC_SIZE
#define PREFIX_SIZE (0)
#else
#if defined(__sun) || defined(__sparc) || defined(__sparc__)
#define PREFIX_SIZE (sizeof(long long))
#else
#define PREFIX_SIZE (sizeof(size_t))
#endif
#endif

/* Provide dmalloc_size() for systems where this function is not provided by
 * malloc itself, given that in that case we store a header with this
 * information as the first bytes of every allocation. */
#ifndef HAVE_MALLOC_SIZE
size_t dmalloc_size(void *ptr) {
    void *realptr = (char*)ptr-PREFIX_SIZE;
    size_t size = *((size_t*)realptr);
    /* Assume at least that all the allocations are padded at sizeof(long) by
     * the underlying allocator. */
    if (size&(sizeof(long)-1)) size += sizeof(long)-(size&(sizeof(long)-1));
    return size+PREFIX_SIZE;
}
#endif

void *
_dalloc(size_t size, const char *name, int line)
{
    void *p;

    ASSERT(size != 0);

#ifdef DUSE_JEMALLOC
    p = je_malloc(size+PREFIX_SIZE);
#else
    p = malloc(size+PREFIX_SIZE);
#endif
    if (p == NULL) {
        log_error("malloc(%zu) failed @ %s:%d", size, name, line);
    } else {
#ifdef HAVE_MALLOC_SIZE
        update_dmalloc_stat_alloc(dmalloc_size(p));
        return p;
#else
        *((size_t*)p) = size;
        update_dmalloc_stat_alloc(size+PREFIX_SIZE);
        return (char*)p+PREFIX_SIZE;
#endif
        log_debug(LOG_VVERB, "malloc(%zu) at %p @ %s:%d", size, p, name, line);
    }

    return p;
}

void *
_dzalloc(size_t size, const char *name, int line)
{
    void *p;

    p = _dalloc(size, name, line);
    if (p != NULL) {
        memset(p, 0, size);
    }

    return p;
}

void *
_dcalloc(size_t nmemb, size_t size, const char *name, int line)
{
    return _dzalloc(nmemb * size, name, line);
}

void *
_drealloc(void *ptr, size_t size, const char *name, int line)
{
#ifndef HAVE_MALLOC_SIZE
    void *realp;
#endif
    void *p;
    size_t oldsize;

    ASSERT(size != 0);

    if (ptr == NULL) return _dalloc(size, name, line);

#ifdef HAVE_MALLOC_SIZE
    oldsize = dmalloc_size(ptr);
#ifdef DUSE_JEMALLOC
    p = je_realloc(ptr, size);
#else
    p = realloc(ptr, size);
#endif
#else
    realp = (char*)ptr-PREFIX_SIZE;
    oldsize = *((size_t*)realp);
#ifdef DUSE_JEMALLOC
    p = je_realloc(ptr, size+PREFIX_SIZE);
#else
    p = realloc(ptr, size+PREFIX_SIZE);
#endif
#endif
    if (p == NULL) {
        log_error("realloc(%zu) failed @ %s:%d", size, name, line);
        return NULL;
    } else {
        log_debug(LOG_VVERB, "realloc(%zu) at %p @ %s:%d", size, p, name, line);
#ifdef HAVE_MALLOC_SIZE
        update_dmalloc_stat_free(oldsize);
        update_dmalloc_stat_alloc(dmalloc_size(p));
        return p;
#else
        *((size_t*)p) = size;
        update_dmalloc_stat_free(oldsize);
        update_dmalloc_stat_alloc(size);
        return p+PREFIX_SIZE;
#endif
    }

    return NULL;
}

void
_dfree(void *ptr, const char *name, int line)
{
#ifndef HAVE_MALLOC_SIZE
    void *realp;
    size_t oldsize;
#endif

    ASSERT(ptr != NULL);
    log_debug(LOG_VVERB, "free(%p) @ %s:%d", ptr, name, line);

#ifdef HAVE_MALLOC_SIZE
    update_dmalloc_stat_free(dmalloc_size(ptr));
#ifdef DUSE_JEMALLOC
    je_free(ptr);
#else
    free(ptr);
#endif
#else
    realp = (char*)ptr-PREFIX_SIZE;
    oldsize = *((size_t*)realp);
    update_dmalloc_stat_free(oldsize+PREFIX_SIZE);
    free(realp);
#ifdef DUSE_JEMALLOC
    je_free(realp);
#else
    free(realp);
#endif
#endif
}

size_t
dalloc_used_memory(void)
{
    size_t um;

#if defined(__ATOMIC_RELAXED) || defined(HAVE_ATOMIC)
    um = update_used_mem_stat_add(0);
#else
    pthread_mutex_lock(&used_memory_mutex);
    um = used_memory;
    pthread_mutex_unlock(&used_memory_mutex);
#endif

    return um;
}

/* Returns the size of physical memory (RAM) in bytes.
 * It looks ugly, but this is the cleanest way to achive cross platform results.
 * Cleaned up from:
 *
 * http://nadeausoftware.com/articles/2012/09/c_c_tip_how_get_physical_memory_size_system
 *
 * Note that this function:
 * 1) Was released under the following CC attribution license:
 *    http://creativecommons.org/licenses/by/3.0/deed.en_US.
 * 2) Was originally implemented by David Robert Nadeau.
 * 3) Was modified for Redis by Matt Stancliff.
 * 4) This note exists in order to comply with the original license.
 */
size_t dalloc_get_memory_size(void) {
#if defined(__unix__) || defined(__unix) || defined(unix) || \
    (defined(__APPLE__) && defined(__MACH__))
#if defined(CTL_HW) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM64))
    int mib[2];
    mib[0] = CTL_HW;
#if defined(HW_MEMSIZE)
    mib[1] = HW_MEMSIZE;            /* OSX. --------------------- */
#elif defined(HW_PHYSMEM64)
    mib[1] = HW_PHYSMEM64;          /* NetBSD, OpenBSD. --------- */
#endif
    int64_t size = 0;               /* 64-bit */
    size_t len = sizeof(size);
    if (sysctl( mib, 2, &size, &len, NULL, 0) == 0)
        return (size_t)size;
    return 0L;          /* Failed? */

#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
    /* FreeBSD, Linux, OpenBSD, and Solaris. -------------------- */
    return (size_t)sysconf(_SC_PHYS_PAGES) * (size_t)sysconf(_SC_PAGESIZE);

#elif defined(CTL_HW) && (defined(HW_PHYSMEM) || defined(HW_REALMEM))
    /* DragonFly BSD, FreeBSD, NetBSD, OpenBSD, and OSX. -------- */
    int mib[2];
    mib[0] = CTL_HW;
#if defined(HW_REALMEM)
    mib[1] = HW_REALMEM;        /* FreeBSD. ----------------- */
#elif defined(HW_PYSMEM)
    mib[1] = HW_PHYSMEM;        /* Others. ------------------ */
#endif
    unsigned int size = 0;      /* 32-bit */
    size_t len = sizeof(size);
    if (sysctl(mib, 2, &size, &len, NULL, 0) == 0)
        return (size_t)size;
    return 0L;          /* Failed? */
#endif /* sysctl and sysconf variants */

#else
    return 0L;          /* Unknown OS. */
#endif
}

/* Get the RSS information in an OS-specific way.
 *
 * WARNING: the function zmalloc_get_rss() is not designed to be fast
 * and may not be called in the busy loops where Redis tries to release
 * memory expiring or swapping out objects.
 *
 * For this kind of "fast RSS reporting" usages use instead the
 * function RedisEstimateRSS() that is a much faster (and less precise)
 * version of the function. */

#if defined(HAVE_PROC_STAT)
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

size_t dalloc_get_rss(void) {
    int page = sysconf(_SC_PAGESIZE);
    size_t rss;
    char buf[4096];
    char filename[256];
    int fd, count;
    char *p, *x;

    snprintf(filename,256,"/proc/%d/stat",getpid());
    if ((fd = open(filename,O_RDONLY)) == -1) return 0;
    if (read(fd,buf,4096) <= 0) {
        close(fd);
        return 0;
    }
    close(fd);

    p = buf;
    count = 23; /* RSS is the 24th field in /proc/<pid>/stat */
    while(p && count--) {
        p = strchr(p,' ');
        if (p) p++;
    }
    if (!p) return 0;
    x = strchr(p,' ');
    if (!x) return 0;
    *x = '\0';

    rss = strtoll(p,NULL,10);
    rss *= page;
    return rss;
}
#elif defined(HAVE_TASKINFO)
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <mach/task.h>
#include <mach/mach_init.h>

size_t dalloc_get_rss(void) {
    task_t task = MACH_PORT_NULL;
    struct task_basic_info t_info;
    mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;

    if (task_for_pid(current_task(), getpid(), &task) != KERN_SUCCESS)
        return 0;
    task_info(task, TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);

    return t_info.resident_size;
}
#else
size_t dalloc_get_rss(void) {
    /* If we can't get the RSS in an OS-specific way for this system just
     * return the memory usage we estimated in dalloc()..
     *
     * Fragmentation will appear to be always 1 (no fragmentation)
     * of course... */
    return dalloc_used_memory();
}
#endif

/* Fragmentation = RSS / allocated-bytes */
float dalloc_get_fragmentation_ratio(size_t rss) {
    return (float)rss/dalloc_used_memory();
}


================================================
FILE: dep/dmalloc/dmalloc.h
================================================
#ifndef _DMALLOC_H_
#define _DMALLOC_H_

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <dspecialconfig.h>

#ifdef HAVE_JEMALLOC
# define DUSE_JEMALLOC 1
#endif

/*
 * Memory allocation and free wrappers.
 *
 * These wrappers enables us to loosely detect double free, dangling
 * pointer access and zero-byte alloc.
 */
#if defined(DUSE_JEMALLOC)
#define DMALLOC_LIB ("jemalloc-" __xstr(JEMALLOC_VERSION_MAJOR) "." __xstr(JEMALLOC_VERSION_MINOR) "." __xstr(JEMALLOC_VERSION_BUGFIX))
#include <jemalloc/jemalloc.h>
#if (JEMALLOC_VERSION_MAJOR == 2 && JEMALLOC_VERSION_MINOR >= 1) || (JEMALLOC_VERSION_MAJOR > 2)
#define HAVE_MALLOC_SIZE 1
#define dmalloc_size(p) je_malloc_usable_size(p)
#else
#error "Newer version of jemalloc required"
#endif
#elif defined(__APPLE__)
#include <malloc/malloc.h>
#define HAVE_MALLOC_SIZE 1
#define dmalloc_size(p) malloc_size(p)
#endif
    
#ifndef DMALLOC_LIB
#define DMALLOC_LIB "libc"
#endif

#define dalloc(_s)                    \
    _dalloc((size_t)(_s), __FILE__, __LINE__)

#define dzalloc(_s)                   \
    _dzalloc((size_t)(_s), __FILE__, __LINE__)

#define dcalloc(_n, _s)               \
    _dcalloc((size_t)(_n), (size_t)(_s), __FILE__, __LINE__)

#define drealloc(_p, _s)              \
    _drealloc(_p, (size_t)(_s), __FILE__, __LINE__)

#define dfree(_p) do {                \
    _dfree(_p, __FILE__, __LINE__);   \
} while (0)

char *dmalloc_lock_type(void);

#ifndef HAVE_MALLOC_SIZE
size_t dmalloc_size(void *ptr);
#endif

void *_dalloc(size_t size, const char *name, int line);
void *_dzalloc(size_t size, const char *name, int line);
void *_dcalloc(size_t nmemb, size_t size, const char *name, int line);
void *_drealloc(void *ptr, size_t size, const char *name, int line);
void _dfree(void *ptr, const char *name, int line);

size_t dalloc_used_memory(void);

size_t dalloc_get_memory_size(void);

size_t dalloc_get_rss(void);
float dalloc_get_fragmentation_ratio(size_t rss);

#endif


================================================
FILE: dep/himemcached-0.1.0/Makefile.am
================================================
MAINTAINERCLEANFILES = Makefile.in

AM_CFLAGS = -Wall -Wshadow
AM_CFLAGS += -Wno-unused-parameter -Wno-unused-value

noinst_LIBRARIES = libhimemcached.a

noinst_HEADERS = himemcached.h himcread.h himcdep/sds.h

libhimemcached_a_SOURCES =          \
    himcdep/sds.c himcdep/sds.h     \
    himcread.c himcread.h           \
	himemcached.c himemcached.h

================================================
FILE: dep/himemcached-0.1.0/himcdep/sds.c
================================================
/* SDS (Simple Dynamic Strings), A C dynamic strings library.
 *
 * Copyright (c) 2006-2014, Salvatore Sanfilippo <antirez at gmail dot com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *   * Neither the name of Redis nor the names of its contributors may be used
 *     to endorse or promote products derived from this software without
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>

#include "sds.h"

/* Create a new sds string with the content specified by the 'init' pointer
 * and 'initlen'.
 * If NULL is used for 'init' the string is initialized with zero bytes.
 *
 * The string is always null-termined (all the sds strings are, always) so
 * even if you create an sds string with:
 *
 * mystring = sdsnewlen("abc",3");
 *
 * You can print the string with printf() as there is an implicit \0 at the
 * end of the string. However the string is binary safe and can contain
 * \0 characters in the middle, as the length is stored in the sds header. */
sds sdsnewlen(const void *init, size_t initlen) {
    struct sdshdr *sh;

    if (init) {
        sh = malloc(sizeof *sh+initlen+1);
    } else {
        sh = calloc(sizeof *sh+initlen+1,1);
    }
    if (sh == NULL) return NULL;
    sh->len = initlen;
    sh->free = 0;
    if (initlen && init)
        memcpy(sh->buf, init, initlen);
    sh->buf[initlen] = '\0';
    return (char*)sh->buf;
}

/* Create an empty (zero length) sds string. Even in this case the string
 * always has an implicit null term. */
sds sdsempty(void) {
    return sdsnewlen("",0);
}

/* Create a new sds string starting from a null termined C string. */
sds sdsnew(const char *init) {
    size_t initlen = (init == NULL) ? 0 : strlen(init);
    return sdsnewlen(init, initlen);
}

/* Duplicate an sds string. */
sds sdsdup(const sds s) {
    return sdsnewlen(s, sdslen(s));
}

/* Free an sds string. No operation is performed if 's' is NULL. */
void sdsfree(sds s) {
    if (s == NULL) return;
    free(s-sizeof(struct sdshdr));
}

/* Set the sds string length to the length as obtained with strlen(), so
 * considering as content only up to the first null term character.
 *
 * This function is useful when the sds string is hacked manually in some
 * way, like in the following example:
 *
 * s = sdsnew("foobar");
 * s[2] = '\0';
 * sdsupdatelen(s);
 * printf("%d\n", sdslen(s));
 *
 * The output will be "2", but if we comment out the call to sdsupdatelen()
 * the output will be "6" as the string was modified but the logical length
 * remains 6 bytes. */
void sdsupdatelen(sds s) {
    struct sdshdr *sh = (void*) (s-sizeof *sh);
    int reallen = strlen(s);
    sh->free += (sh->len-reallen);
    sh->len = reallen;
}

/* Modify an sds string on-place to make it empty (zero length).
 * However all the existing buffer is not discarded but set as free space
 * so that next append operations will not require allocations up to the
 * number of bytes previously available. */
void sdsclear(sds s) {
    struct sdshdr *sh = (void*) (s-sizeof *sh);
    sh->free += sh->len;
    sh->len = 0;
    sh->buf[0] = '\0';
}

/* Enlarge the free space at the end of the sds string so that the caller
 * is sure that after calling this function can overwrite up to addlen
 * bytes after the end of the string, plus one more byte for nul term.
 *
 * Note: this does not change the *length* of the sds string as returned
 * by sdslen(), but only the free buffer space we have. */
sds sdsMakeRoomFor(sds s, size_t addlen) {
    struct sdshdr *sh, *newsh;
    size_t free = sdsavail(s);
    size_t len, newlen;

    if (free >= addlen) return s;
    len = sdslen(s);
    sh = (void*) (s-sizeof *sh);
    newlen = (len+addlen);
    if (newlen < SDS_MAX_PREALLOC)
        newlen *= 2;
    else
        newlen += SDS_MAX_PREALLOC;
    newsh = realloc(sh, sizeof *newsh+newlen+1);
    if (newsh == NULL) return NULL;

    newsh->free = newlen - len;
    return newsh->buf;
}

/* Reallocate the sds string so that it has no free space at the end. The
 * contained string remains not altered, but next concatenation operations
 * will require a reallocation.
 *
 * After the call, the passed sds string is no longer valid and all the
 * references must be substituted with the new pointer returned by the call. */
sds sdsRemoveFreeSpace(sds s) {
    struct sdshdr *sh;

    sh = (void*) (s-sizeof *sh);
    sh = realloc(sh, sizeof *sh+sh->len+1);
    sh->free = 0;
    return sh->buf;
}

/* Return the total size of the allocation of the specifed sds string,
 * including:
 * 1) The sds header before the pointer.
 * 2) The string.
 * 3) The free buffer at the end if any.
 * 4) The implicit null term.
 */
size_t sdsAllocSize(sds s) {
    struct sdshdr *sh = (void*) (s-sizeof *sh);

    return sizeof(*sh)+sh->len+sh->free+1;
}

/* Increment the sds length and decrements the left free space at the
 * end of the string according to 'incr'. Also set the null term
 * in the new end of the string.
 *
 * This function is used in order to fix the string length after the
 * user calls sdsMakeRoomFor(), writes something after the end of
 * the current string, and finally needs to set the new length.
 *
 * Note: it is possible to use a negative increment in order to
 * right-trim the string.
 *
 * Usage example:
 *
 * Using sdsIncrLen() and sdsMakeRoomFor() it is possible to mount the
 * following schema, to cat bytes coming from the kernel to the end of an
 * sds string without copying into an intermediate buffer:
 *
 * oldlen = sdslen(s);
 * s = sdsMakeRoomFor(s, BUFFER_SIZE);
 * nread = read(fd, s+oldlen, BUFFER_SIZE);
 * ... check for nread <= 0 and handle it ...
 * sdsIncrLen(s, nread);
 */
void sdsIncrLen(sds s, int incr) {
    struct sdshdr *sh = (void*) (s-sizeof *sh);

    assert(sh->free >= incr);
    sh->len += incr;
    sh->free -= incr;
    assert(sh->free >= 0);
    s[sh->len] = '\0';
}

/* Grow the sds to have the specified length. Bytes that were not part of
 * the original length of the sds will be set to zero.
 *
 * if the specified length is smaller than the current length, no operation
 * is performed. */
sds sdsgrowzero(sds s, size_t len) {
    struct sdshdr *sh = (void*) (s-sizeof *sh);
    size_t totlen, curlen = sh->len;

    if (len <= curlen) return s;
    s = sdsMakeRoomFor(s,len-curlen);
    if (s == NULL) return NULL;

    /* Make sure added region doesn't contain garbage */
    sh = (void*)(s-sizeof *sh);
    memset(s+curlen,0,(len-curlen+1)); /* also set trailing \0 byte */
    totlen = sh->len+sh->free;
    sh->len = len;
    sh->free = totlen-sh->len;
    return s;
}

/* Append the specified binary-safe string pointed by 't' of 'len' bytes to the
 * end of the specified sds string 's'.
 *
 * After the call, the passed sds string is no longer valid and all the
 * references must be substituted with the new pointer returned by the call. */
sds sdscatlen(sds s, const void *t, size_t len) {
    struct sdshdr *sh;
    size_t curlen = sdslen(s);

    s = sdsMakeRoomFor(s,len);
    if (s == NULL) return NULL;
    sh = (void*) (s-sizeof *sh);
    memcpy(s+curlen, t, len);
    sh->len = curlen+len;
    sh->free = sh->free-len;
    s[curlen+len] = '\0';
    return s;
}

/* Append the specified null termianted C string to the sds string 's'.
 *
 * After the call, the passed sds string is no longer valid and all the
 * references must be substituted with the new pointer returned by the call. */
sds sdscat(sds s, const char *t) {
    return sdscatlen(s, t, strlen(t));
}

/* Append the specified sds 't' to the existing sds 's'.
 *
 * After the call, the modified sds string is no longer valid and all the
 * references must be substituted with the new pointer returned by the call. */
sds sdscatsds(sds s, const sds t) {
    return sdscatlen(s, t, sdslen(t));
}

/* Destructively modify the sds string 's' to hold the specified binary
 * safe string pointed by 't' of length 'len' bytes. */
sds sdscpylen(sds s, const char *t, size_t len) {
    struct sdshdr *sh = (void*) (s-sizeof *sh);
    size_t totlen = sh->free+sh->len;

    if (totlen < len) {
        s = sdsMakeRoomFor(s,len-sh->len);
        if (s == NULL) return NULL;
        sh = (void*) (s-sizeof *sh);
        totlen = sh->free+sh->len;
    }
    memcpy(s, t, len);
    s[len] = '\0';
    sh->len = len;
    sh->free = totlen-len;
    return s;
}

/* Like sdscpylen() but 't' must be a null-termined string so that the length
 * of the string is obtained with strlen(). */
sds sdscpy(sds s, const char *t) {
    return sdscpylen(s, t, strlen(t));
}

/* Helper for sdscatlonglong() doing the actual number -> string
 * conversion. 's' must point to a string with room for at least
 * SDS_LLSTR_SIZE bytes.
 *
 * The function returns the lenght of the null-terminated string
 * representation stored at 's'. */
#define SDS_LLSTR_SIZE 21
int sdsll2str(char *s, long long value) {
    char *p, aux;
    unsigned long long v;
    size_t l;

    /* Generate the string representation, this method produces
     * an reversed string. */
    v = (value < 0) ? -value : value;
    p = s;
    do {
        *p++ = '0'+(v%10);
        v /= 10;
    } while(v);
    if (value < 0) *p++ = '-';

    /* Compute length and add null term. */
    l = p-s;
    *p = '\0';

    /* Reverse the string. */
    p--;
    while(s < p) {
        aux = *s;
        *s = *p;
        *p = aux;
        s++;
        p--;
    }
    return l;
}

/* Identical sdsll2str(), but for unsigned long long type. */
int sdsull2str(char *s, unsigned long long v) {
    char *p, aux;
    size_t l;

    /* Generate the string representation, this method produces
     * an reversed string. */
    p = s;
    do {
        *p++ = '0'+(v%10);
        v /= 10;
    } while(v);

    /* Compute length and add null term. */
    l = p-s;
    *p = '\0';

    /* Reverse the string. */
    p--;
    while(s < p) {
        aux = *s;
        *s = *p;
        *p = aux;
        s++;
        p--;
    }
    return l;
}

/* Like sdscatpritf() but gets va_list instead of being variadic. */
sds sdscatvprintf(sds s, const char *fmt, va_list ap) {
    va_list cpy;
    char *buf, *t;
    size_t buflen = 16;

    while(1) {
        buf = malloc(buflen);
        if (buf == NULL) return NULL;
        buf[buflen-2] = '\0';
        va_copy(cpy,ap);
        vsnprintf(buf, buflen, fmt, cpy);
        if (buf[buflen-2] != '\0') {
            free(buf);
            buflen *= 2;
            continue;
        }
        break;
    }
    t = sdscat(s, buf);
    free(buf);
    return t;
}

/* Append to the sds string 's' a string obtained using printf-alike format
 * specifier.
 *
 * After the call, the modified sds string is no longer valid and all the
 * references must be substituted with the new pointer returned by the call.
 *
 * Example:
 *
 * s = sdsnew("Sum is: ");
 * s = sdscatprintf(s,"%d+%d = %d",a,b,a+b);
 *
 * Often you need to create a string from scratch with the printf-alike
 * format. When this is the need, just use sdsempty() as the target string:
 *
 * s = sdscatprintf(sdsempty(), "... your format ...", args);
 */
sds sdscatprintf(sds s, const char *fmt, ...) {
    va_list ap;
    char *t;
    va_start(ap, fmt);
    t = sdscatvprintf(s,fmt,ap);
    va_end(ap);
    return t;
}

/* This function is similar to sdscatprintf, but much faster as it does
 * not rely on sprintf() family functions implemented by the libc that
 * are often very slow. Moreover directly handling the sds string as
 * new data is concatenated provides a performance improvement.
 *
 * However this function only handles an incompatible subset of printf-alike
 * format specifiers:
 *
 * %s - C String
 * %S - SDS string
 * %i - signed int
 * %I - 64 bit signed integer (long long, int64_t)
 * %u - unsigned int
 * %U - 64 bit unsigned integer (unsigned long long, uint64_t)
 * %T - A size_t variable.
 * %% - Verbatim "%" character.
 */
sds sdscatfmt(sds s, char const *fmt, ...) {
    struct sdshdr *sh = (void*) (s-(sizeof(struct sdshdr)));
    size_t initlen = sdslen(s);
    const char *f = fmt;
    int i;
    va_list ap;

    va_start(ap,fmt);
    f = fmt;    /* Next format specifier byte to process. */
    i = initlen; /* Position of the next byte to write to dest str. */
    while(*f) {
        char next, *str;
        int l;
        long long num;
        unsigned long long unum;

        /* Make sure there is always space for at least 1 char. */
        if (sh->free == 0) {
            s = sdsMakeRoomFor(s,1);
            sh = (void*) (s-(sizeof(struct sdshdr)));
        }

        switch(*f) {
        case '%':
            next = *(f+1);
            f++;
            switch(next) {
            case 's':
            case 'S':
                str = va_arg(ap,char*);
                l = (next == 's') ? strlen(str) : sdslen(str);
                if (sh->free < l) {
                    s = sdsMakeRoomFor(s,l);
                    sh = (void*) (s-(sizeof(struct sdshdr)));
                }
                memcpy(s+i,str,l);
                sh->len += l;
                sh->free -= l;
                i += l;
                break;
            case 'i':
            case 'I':
                if (next == 'i')
                    num = va_arg(ap,int);
                else
                    num = va_arg(ap,long long);
                {
                    char buf[SDS_LLSTR_SIZE];
                    l = sdsll2str(buf,num);
                    if (sh->free < l) {
                        s = sdsMakeRoomFor(s,l);
                        sh = (void*) (s-(sizeof(struct sdshdr)));
                    }
                    memcpy(s+i,buf,l);
                    sh->len += l;
                    sh->free -= l;
                    i += l;
                }
                break;
            case 'u':
            case 'U':
            case 'T':
                if (next == 'u')
                    unum = va_arg(ap,unsigned int);
                else if(next == 'U')
                    unum = va_arg(ap,unsigned long long);
                else
                    unum = (unsigned long long)va_arg(ap,size_t);
                {
                    char buf[SDS_LLSTR_SIZE];
                    l = sdsull2str(buf,unum);
                    if (sh->free < l) {
                        s = sdsMakeRoomFor(s,l);
                        sh = (void*) (s-(sizeof(struct sdshdr)));
                    }
                    memcpy(s+i,buf,l);
                    sh->len += l;
                    sh->free -= l;
                    i += l;
                }
                break;
            default: /* Handle %% and generally %<unknown>. */
                s[i++] = next;
                sh->len += 1;
                sh->free -= 1;
                break;
            }
            break;
        default:
            s[i++] = *f;
            sh->len += 1;
            sh->free -= 1;
            break;
        }
        f++;
    }
    va_end(ap);

    /* Add null-term */
    s[i] = '\0';
    return s;
}


/* Remove the part of the string from left and from right composed just of
 * contiguous characters found in 'cset', that is a null terminted C string.
 *
 * After the call, the modified sds string is no longer valid and all the
 * references must be substituted with the new pointer returned by the call.
 *
 * Example:
 *
 * s = sdsnew("AA...AA.a.aa.aHelloWorld     :::");
 * s = sdstrim(s,"A. :");
 * printf("%s\n", s);
 *
 * Output will be just "Hello World".
 */
void sdstrim(sds s, const char *cset) {
    struct sdshdr *sh = (void*) (s-sizeof *sh);
    char *start, *end, *sp, *ep;
    size_t len;

    sp = start = s;
    ep = end = s+sdslen(s)-1;
    while(sp <= end && strchr(cset, *sp)) sp++;
    while(ep > start && strchr(cset, *ep)) ep--;
    len = (sp > ep) ? 0 : ((ep-sp)+1);
    if (sh->buf != sp) memmove(sh->buf, sp, len);
    sh->buf[len] = '\0';
    sh->free = sh->free+(sh->len-len);
    sh->len = len;
}

/* Turn the string into a smaller (or equal) string containing only the
 * substring specified by the 'start' and 'end' indexes.
 *
 * start and end can be negative, where -1 means the last character of the
 * string, -2 the penultimate character, and so forth.
 *
 * The interval is inclusive, so the start and end characters will be part
 * of the resulting string.
 *
 * The string is modified in-place.
 *
 * Example:
 *
 * s = sdsnew("Hello World");
 * sdsrange(s,1,-1); => "ello World"
 */
void sdsrange(sds s, int start, int end) {
    struct sdshdr *sh = (void*) (s-sizeof *sh);
    size_t newlen, len = sdslen(s);

    if (len == 0) return;
    if (start < 0) {
        start = len+start;
        if (start < 0) start = 0;
    }
    if (end < 0) {
        end = len+end;
        if (end < 0) end = 0;
    }
    newlen = (start > end) ? 0 : (end-start)+1;
    if (newlen != 0) {
        if (start >= (signed)len) {
            newlen = 0;
        } else if (end >= (signed)len) {
            end = len-1;
            newlen = (start > end) ? 0 : (end-start)+1;
        }
    } else {
        start = 0;
    }
    if (start && newlen) memmove(sh->buf, sh->buf+start, newlen);
    sh->buf[newlen] = 0;
    sh->free = sh->free+(sh->len-newlen);
    sh->len = newlen;
}

/* Apply tolower() to every character of the sds string 's'. */
void sdstolower(sds s) {
    int len = sdslen(s), j;

    for (j = 0; j < len; j++) s[j] = tolower(s[j]);
}

/* Apply toupper() to every character of the sds string 's'. */
void sdstoupper(sds s) {
    int len = sdslen(s), j;

    for (j = 0; j < len; j++) s[j] = toupper(s[j]);
}

/* Compare two sds strings s1 and s2 with memcmp().
 *
 * Return value:
 *
 *     1 if s1 > s2.
 *    -1 if s1 < s2.
 *     0 if s1 and s2 are exactly the same binary string.
 *
 * If two strings share exactly the same prefix, but one of the two has
 * additional characters, the longer string is considered to be greater than
 * the smaller one. */
int sdscmp(const sds s1, const sds s2) {
    size_t l1, l2, minlen;
    int cmp;

    l1 = sdslen(s1);
    l2 = sdslen(s2);
    minlen = (l1 < l2) ? l1 : l2;
    cmp = memcmp(s1,s2,minlen);
    if (cmp == 0) return l1-l2;
    return cmp;
}

/* Split 's' with separator in 'sep'. An array
 * of sds strings is returned. *count will be set
 * by reference to the number of tokens returned.
 *
 * On out of memory, zero length string, zero length
 * separator, NULL is returned.
 *
 * Note that 'sep' is able to split a string using
 * a multi-character separator. For example
 * sdssplit("foo_-_bar","_-_"); will return two
 * elements "foo" and "bar".
 *
 * This version of the function is binary-safe but
 * requires length arguments. sdssplit() is just the
 * same function but for zero-terminated strings.
 */
sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count) {
    int elements = 0, slots = 5, start = 0, j;
    sds *tokens;

    if (seplen < 1 || len < 0) return NULL;

    tokens = malloc(sizeof(sds)*slots);
    if (tokens == NULL) return NULL;

    if (len == 0) {
        *count = 0;
        return tokens;
    }
    for (j = 0; j < (len-(seplen-1)); j++) {
        /* make sure there is room for the next element and the final one */
        if (slots < elements+2) {
            sds *newtokens;

            slots *= 2;
            newtokens = realloc(tokens,sizeof(sds)*slots);
            if (newtokens == NULL) goto cleanup;
            tokens = newtokens;
        }
        /* search the separator */
        if ((seplen == 1 && *(s+j) == sep[0]) || (memcmp(s+j,sep,seplen) == 0)) {
            tokens[elements] = sdsnewlen(s+start,j-start);
            if (tokens[elements] == NULL) goto cleanup;
            elements++;
            start = j+seplen;
            j = j+seplen-1; /* skip the separator */
        }
    }
    /* Add the final element. We are sure there is room in the tokens array. */
    tokens[elements] = sdsnewlen(s+start,len-start);
    if (tokens[elements] == NULL) goto cleanup;
    elements++;
    *count = elements;
    return tokens;

cleanup:
    {
        int i;
        for (i = 0; i < elements; i++) sdsfree(tokens[i]);
        free(tokens);
        *count = 0;
        return NULL;
    }
}

/* Free the result returned by sdssplitlen(), or do nothing if 'tokens' is NULL. */
void sdsfreesplitres(sds *tokens, int count) {
    if (!tokens) return;
    while(count--)
        sdsfree(tokens[count]);
    free(tokens);
}

/* Create an sds string from a long long value. It is much faster than:
 *
 * sdscatprintf(sdsempty(),"%lld\n", value);
 */
sds sdsfromlonglong(long long value) {
    char buf[32], *p;
    unsigned long long v;

    v = (value < 0) ? -value : value;
    p = buf+31; /* point to the last character */
    do {
        *p-- = '0'+(v%10);
        v /= 10;
    } while(v);
    if (value < 0) *p-- = '-';
    p++;
    return sdsnewlen(p,32-(p-buf));
}

/* Append to the sds string "s" an escaped string representation where
 * all the non-printable characters (tested with isprint()) are turned into
 * escapes in the form "\n\r\a...." or "\x<hex-number>".
 *
 * After the call, the modified sds string is no longer valid and all the
 * references must be substituted with the new pointer returned by the call. */
sds sdscatrepr(sds s, const char *p, size_t len) {
    s = sdscatlen(s,"\"",1);
    while(len--) {
        switch(*p) {
        case '\\':
        case '"':
            s = sdscatprintf(s,"\\%c",*p);
            break;
        case '\n': s = sdscatlen(s,"\\n",2); break;
        case '\r': s = sdscatlen(s,"\\r",2); break;
        case '\t': s = sdscatlen(s,"\\t",2); break;
        case '\a': s = sdscatlen(s,"\\a",2); break;
        case '\b': s = sdscatlen(s,"\\b",2); break;
        default:
            if (isprint(*p))
                s = sdscatprintf(s,"%c",*p);
            else
                s = sdscatprintf(s,"\\x%02x",(unsigned char)*p);
            break;
        }
        p++;
    }
    return sdscatlen(s,"\"",1);
}

/* Helper function for sdssplitargs() that returns non zero if 'c'
 * is a valid hex digit. */
int is_hex_digit(char c) {
    return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
           (c >= 'A' && c <= 'F');
}

/* Helper function for sdssplitargs() that converts a hex digit into an
 * integer from 0 to 15 */
int hex_digit_to_int(char c) {
    switch(c) {
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    case 'a': case 'A': return 10;
    case 'b': case 'B': return 11;
    case 'c': case 'C': return 12;
    case 'd': case 'D': return 13;
    case 'e': case 'E': return 14;
    case 'f': case 'F': return 15;
    default: return 0;
    }
}

/* Split a line into arguments, where every argument can be in the
 * following programming-language REPL-alike form:
 *
 * foo bar "newline are supported\n" and "\xff\x00otherstuff"
 *
 * The number of arguments is stored into *argc, and an array
 * of sds is returned.
 *
 * The caller should free the resulting array of sds strings with
 * sdsfreesplitres().
 *
 * Note that sdscatrepr() is able to convert back a string into
 * a quoted string in the same format sdssplitargs() is able to parse.
 *
 * The function returns the allocated tokens on success, even when the
 * input string is empty, or NULL if the input contains unbalanced
 * quotes or closed quotes followed by non space characters
 * as in: "foo"bar or "foo'
 */
sds *sdssplitargs(const char *line, int *argc) {
    const char *p = line;
    char *current = NULL;
    char **vector = NULL;

    *argc = 0;
    while(1) {
        /* skip blanks */
        while(*p && isspace(*p)) p++;
        if (*p) {
            /* get a token */
            int inq=0;  /* set to 1 if we are in "quotes" */
            int insq=0; /* set to 1 if we are in 'single quotes' */
            int done=0;

            if (current == NULL) current = sdsempty();
            while(!done) {
                if (inq) {
                    if (*p == '\\' && *(p+1) == 'x' &&
                                             is_hex_digit(*(p+2)) &&
                                             is_hex_digit(*(p+3)))
                    {
                        unsigned char byte;

                        byte = (hex_digit_to_int(*(p+2))*16)+
                                hex_digit_to_int(*(p+3));
                        current = sdscatlen(current,(char*)&byte,1);
                        p += 3;
                    } else if (*p == '\\' && *(p+1)) {
                        char c;

                        p++;
                        switch(*p) {
                        case 'n': c = '\n'; break;
                        case 'r': c = '\r'; break;
                        case 't': c = '\t'; break;
                        case 'b': c = '\b'; break;
                        case 'a': c = '\a'; break;
                        default: c = *p; break;
                        }
                        current = sdscatlen(current,&c,1);
                    } else if (*p == '"') {
                        /* closing quote must be followed by a space or
                         * nothing at all. */
                        if (*(p+1) && !isspace(*(p+1))) goto err;
                        done=1;
                    } else if (!*p) {
                        /* unterminated quotes */
                        goto err;
                    } else {
                        current = sdscatlen(current,p,1);
                    }
                } else if (insq) {
                    if (*p == '\\' && *(p+1) == '\'') {
                        p++;
                        current = sdscatlen(current,"'",1);
                    } else if (*p == '\'') {
                        /* closing quote must be followed by a space or
                         * nothing at all. */
                        if (*(p+1) && !isspace(*(p+1))) goto err;
                        done=1;
                    } else if (!*p) {
                        /* unterminated quotes */
                        goto err;
                    } else {
                        current = sdscatlen(current,p,1);
                    }
                } else {
                    switch(*p) {
                    case ' ':
                    case '\n':
                    case '\r':
                    case '\t':
                    case '\0':
                        done=1;
                        break;
                    case '"':
                        inq=1;
                        break;
                    case '\'':
                        insq=1;
                        break;
                    default:
                        current = sdscatlen(current,p,1);
                        break;
                    }
                }
                if (*p) p++;
            }
            /* add the token to the vector */
            vector = realloc(vector,((*argc)+1)*sizeof(char*));
            vector[*argc] = current;
            (*argc)++;
            current = NULL;
        } else {
            /* Even on empty input string return something not NULL. */
            if (vector == NULL) vector = malloc(sizeof(void*));
            return vector;
        }
    }

err:
    while((*argc)--)
        sdsfree(vector[*argc]);
    free(vector);
    if (current) sdsfree(current);
    *argc = 0;
    return NULL;
}

/* Modify the string substituting all the occurrences of the set of
 * characters specified in the 'from' string to the corresponding character
 * in the 'to' array.
 *
 * For instance: sdsmapchars(mystring, "ho", "01", 2)
 * will have the effect of turning the string "hello" into "0ell1".
 *
 * The function returns the sds string pointer, that is always the same
 * as the input pointer since no resize is needed. */
sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen) {
    size_t j, i, l = sdslen(s);

    for (j = 0; j < l; j++) {
        for (i = 0; i < setlen; i++) {
            if (s[j] == from[i]) {
                s[j] = to[i];
                break;
            }
        }
    }
    return s;
}

/* Join an array of C strings using the specified separator (also a C string).
 * Returns the result as an sds string. */
sds sdsjoin(char **argv, int argc, char *sep, size_t seplen) {
    sds join = sdsempty();
    int j;

    for (j = 0; j < argc; j++) {
        join = sdscat(join, argv[j]);
        if (j != argc-1) join = sdscatlen(join,sep,seplen);
    }
    return join;
}

/* Like sdsjoin, but joins an array of SDS strings. */
sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen) {
    sds join = sdsempty();
    int j;

    for (j = 0; j < argc; j++) {
        join = sdscatsds(join, argv[j]);
        if (j != argc-1) join = sdscatlen(join,sep,seplen);
    }
    return join;
}

#ifdef SDS_TEST_MAIN
#include <stdio.h>
#include "testhelp.h"

int main(void) {
    {
        struct sdshdr *sh;
        sds x = sdsnew("foo"), y;

        test_cond("Create a string and obtain the length",
            sdslen(x) == 3 && memcmp(x,"foo\0",4) == 0)

        sdsfree(x);
        x = sdsnewlen("foo",2);
        test_cond("Create a string with specified length",
            sdslen(x) == 2 && memcmp(x,"fo\0",3) == 0)

        x = sdscat(x,"bar");
        test_cond("Strings concatenation",
            sdslen(x) == 5 && memcmp(x,"fobar\0",6) == 0);

        x = sdscpy(x,"a");
        test_cond("sdscpy() against an originally longer string",
            sdslen(x) == 1 && memcmp(x,"a\0",2) == 0)

        x = sdscpy(x,"xyzxxxxxxxxxxyyyyyyyyyykkkkkkkkkk");
        test_cond("sdscpy() against an originally shorter string",
            sdslen(x) == 33 &&
            memcmp(x,"xyzxxxxxxxxxxyyyyyyyyyykkkkkkkkkk\0",33) == 0)

        sdsfree(x);
        x = sdscatprintf(sdsempty(),"%d",123);
        test_cond("sdscatprintf() seems working in the base case",
            sdslen(x) == 3 && memcmp(x,"123\0",4) ==0)

        sdsfree(x);
        x = sdsnew("xxciaoyyy");
        sdstrim(x,"xy");
        test_cond("sdstrim() correctly trims characters",
            sdslen(x) == 4 && memcmp(x,"ciao\0",5) == 0)

        y = sdsdup(x);
        sdsrange(y,1,1);
        test_cond("sdsrange(...,1,1)",
            sdslen(y) == 1 && memcmp(y,"i\0",2) == 0)

        sdsfree(y);
        y = sdsdup(x);
        sdsrange(y,1,-1);
        test_cond("sdsrange(...,1,-1)",
            sdslen(y) == 3 && memcmp(y,"iao\0",4) == 0)

        sdsfree(y);
        y = sdsdup(x);
        sdsrange(y,-2,-1);
        test_cond("sdsrange(...,-2,-1)",
            sdslen(y) == 2 && memcmp(y,"ao\0",3) == 0)

        sdsfree(y);
        y = sdsdup(x);
        sdsrange(y,2,1);
        test_cond("sdsrange(...,2,1)",
            sdslen(y) == 0 && memcmp(y,"\0",1) == 0)

        sdsfree(y);
        y = sdsdup(x);
        sdsrange(y,1,100);
        test_cond("sdsrange(...,1,100)",
            sdslen(y) == 3 && memcmp(y,"iao\0",4) == 0)

        sdsfree(y);
        y = sdsdup(x);
        sdsrange(y,100,100);
        test_cond("sdsrange(...,100,100)",
            sdslen(y) == 0 && memcmp(y,"\0",1) == 0)

        sdsfree(y);
        sdsfree(x);
        x = sdsnew("foo");
        y = sdsnew("foa");
        test_cond("sdscmp(foo,foa)", sdscmp(x,y) > 0)

        sdsfree(y);
        sdsfree(x);
        x = sdsnew("bar");
        y = sdsnew("bar");
        test_cond("sdscmp(bar,bar)", sdscmp(x,y) == 0)

        sdsfree(y);
        sdsfree(x);
        x = sdsnew("aar");
        y = sdsnew("bar");
        test_cond("sdscmp(bar,bar)", sdscmp(x,y) < 0)

        sdsfree(y);
        sdsfree(x);
        x = sdsnewlen("\a\n\0foo\r",7);
        y = sdscatrepr(sdsempty(),x,sdslen(x));
        test_cond("sdscatrepr(...data...)",
            memcmp(y,"\"\\a\\n\\x00foo\\r\"",15) == 0)

        {
            int oldfree;

            sdsfree(x);
            x = sdsnew("0");
            sh = (void*) (x-(sizeof(struct sdshdr)));
            test_cond("sdsnew() free/len buffers", sh->len == 1 && sh->free == 0);
            x = sdsMakeRoomFor(x,1);
            sh = (void*) (x-(sizeof(struct sdshdr)));
            test_cond("sdsMakeRoomFor()", sh->len == 1 && sh->free > 0);
            oldfree = sh->free;
            x[1] = '1';
            sdsIncrLen(x,1);
            test_cond("sdsIncrLen() -- content", x[0] == '0' && x[1] == '1');
            test_cond("sdsIncrLen() -- len", sh->len == 2);
            test_cond("sdsIncrLen() -- free", sh->free == oldfree-1);
        }
    }
    test_report()
    return 0;
}
#endif


================================================
FILE: dep/himemcached-0.1.0/himcdep/sds.h
================================================
/* SDS (Simple Dynamic Strings), A C dynamic strings library.
 *
 * Copyright (c) 2006-2014, Salvatore Sanfilippo <antirez at gmail dot com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *   * Neither the name of Redis nor the names of its contributors may be used
 *     to endorse or promote products derived from this software without
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __SDS_H
#define __SDS_H

#define SDS_MAX_PREALLOC (1024*1024)

#include <sys/types.h>
#include <stdarg.h>
#ifdef _MSC_VER
#include "win32.h"
#endif

typedef char *sds;

struct sdshdr {
    int len;
    int free;
    char buf[];
};

static inline size_t sdslen(const sds s) {
    struct sdshdr *sh = (struct sdshdr *)(s-sizeof *sh);
    return sh->len;
}

static inline size_t sdsavail(const sds s) {
    struct sdshdr *sh = (struct sdshdr *)(s-sizeof *sh);
    return sh->free;
}

sds sdsnewlen(const void *init, size_t initlen);
sds sdsnew(const char *init);
sds sdsempty(void);
size_t sdslen(const sds s);
sds sdsdup(const sds s);
void sdsfree(sds s);
size_t sdsavail(const sds s);
sds sdsgrowzero(sds s, size_t len);
sds sdscatlen(sds s, const void *t, size_t len);
sds sdscat(sds s, const char *t);
sds sdscatsds(sds s, const sds t);
sds sdscpylen(sds s, const char *t, size_t len);
sds sdscpy(sds s, const char *t);

sds sdscatvprintf(sds s, const char *fmt, va_list ap);
#ifdef __GNUC__
sds sdscatprintf(sds s, const char *fmt, ...)
    __attribute__((format(printf, 2, 3)));
#else
sds sdscatprintf(sds s, const char *fmt, ...);
#endif

sds sdscatfmt(sds s, char const *fmt, ...);
void sdstrim(sds s, const char *cset);
void sdsrange(sds s, int start, int end);
void sdsupdatelen(sds s);
void sdsclear(sds s);
int sdscmp(const sds s1, const sds s2);
sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count);
void sdsfreesplitres(sds *tokens, int count);
void sdstolower(sds s);
void sdstoupper(sds s);
sds sdsfromlonglong(long long value);
sds sdscatrepr(sds s, const char *p, size_t len);
sds *sdssplitargs(const char *line, int *argc);
sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen);
sds sdsjoin(char **argv, int argc, char *sep, size_t seplen);
sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen);

/* Low level functions exposed to the user API */
sds sdsMakeRoomFor(sds s, size_t addlen);
void sdsIncrLen(sds s, int incr);
sds sdsRemoveFreeSpace(sds s);
size_t sdsAllocSize(sds s);

#endif


================================================
FILE: dep/himemcached-0.1.0/himcread.c
================================================
#include <string.h>
#include <stdlib.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <assert.h>
#include <errno.h>
#include <ctype.h>

#include "himcread.h"
#include "himcdep/sds.h"

#define PARSE_OK    0        /* Parsing ok */
#define PARSE_ERROR 1        /* Parsing error */
#define PARSE_AGAIN 3        /* Incomplete -> parse again */

#define RSP_TYPE_UNKNOWN        0
#define RSP_TYPE_NUM            1
#define RSP_TYPE_STORED         2
#define RSP_TYPE_NOT_STORED     3
#define RSP_TYPE_EXISTS         4
#define RSP_TYPE_NOT_FOUND      5
#define RSP_TYPE_END            6
#define RSP_TYPE_VALUE          7
#define RSP_TYPE_DELETED        8
#define RSP_TYPE_ERROR          9
#define RSP_TYPE_CLIENT_ERROR   10
#define RSP_TYPE_SERVER_ERROR   11

static void memcachedReaderReset(mcReader *r);

static void __memcachedReaderSetError(mcReader *r, int type, const char *str) {
    size_t len;

    memcachedReaderReset(r);

    /* Clear input buffer on errors. */
    if (r->buf != NULL) {
        sdsfree(r->buf);
        r->buf = NULL;
        r->pos = r->len = 0;
    }

    /* Set error. */
    r->err = type;
    len = strlen(str);
    len = len < (sizeof(r->errstr)-1) ? len : (sizeof(r->errstr)-1);
    memcpy(r->errstr,str,len);
    r->errstr[len] = '\0';
}

static size_t chrtos(char *buf, size_t size, char byte) 
{
    size_t len = 0;

    switch(byte) {
    case '\\':
    case '"':
        len = snprintf(buf,size,"\"\\%c\"",byte);
        break;
    case '\n': len = snprintf(buf,size,"\"\\n\""); break;
    case '\r': len = snprintf(buf,size,"\"\\r\""); break;
    case '\t': len = snprintf(buf,size,"\"\\t\""); break;
    case '\a': len = snprintf(buf,size,"\"\\a\""); break;
    case '\b': len = snprintf(buf,size,"\"\\b\""); break;
    default:
        if (isprint(byte))
            len = snprintf(buf,size,"\"%c\"",byte);
        else
            len = snprintf(buf,size,"\"\\x%02x\"",(unsigned char)byte);
        break;
    }

    return len;
}

static void __memcachedReaderSetErrorProtocolByte(mcReader *r, char byte) {
    char cbuf[8], sbuf[128];

    chrtos(cbuf,sizeof(cbuf),byte);
    snprintf(sbuf,sizeof(sbuf),
        "Protocol error, got %s as reply type byte", cbuf);
    __memcachedReaderSetError(r,MC_ERR_PROTOCOL,sbuf);
}

static void __memcachedReaderSetErrorOOM(mcReader *r) {
    __memcachedReaderSetError(r,MC_ERR_OOM,"Out of memory");
}

static int elementArrayCreate(mcReader *r)
{
    assert(r->alloc_len == 0);
    assert(r->element == NULL);
    assert(r->elements == 0);

    r->element = malloc(10*sizeof(void*));
    if (r->element == NULL) {
        __memcachedReaderSetErrorOOM(r);
        return MC_ERR;
    }
    r->alloc_len = 10;
    r->elements = 0;
    
    return MC_OK;
}

static void elementArrayDestroy(mcReader *r)
{
    unsigned int i;

    if (r->element == NULL)
        return;

    if (r->fn && r->fn->freeObject) {
        for (i = 0; i < r->elements; i ++) {
            if (r->element[i])
                r->fn->freeObject(r->element[i]);
        }
    }
    free(r->element);
    r->element = NULL;
    r->elements = 0;
    r->alloc_len = 0;
    
    return MC_OK;
}

#define EXPAND_MAX_SIZE_PER_TIME 300
static int elementArrayExpand(mcReader *r) 
{
    size_t new_length;
    if (r->alloc_len <= 150) {
        new_length = r->alloc_len*2;
    } else if (r->alloc_len <= 500) {
        new_length = r->alloc_len+EXPAND_MAX_SIZE_PER_TIME;
    }
    r->element = realloc(r->element,new_length*sizeof(void*));
    if (r->element == NULL) {
        __memcachedReaderSetErrorOOM(r);
        return MC_ERR;
    }
    r->alloc_len = new_length;

    return MC_OK;
}

static int elementArrayAdd(mcReader *r, void *reply)
{
    assert(r->elements <= r->alloc_len);
    if (r->elements == r->alloc_len) {
        if (elementArrayExpand(r) != MC_OK)
            return MC_ERR;
    }
    r->element[r->elements++] = reply;

    return MC_OK;
}

static void memcachedParseResponse(mcReader *r)
{
    void *obj;
    char *p, *m;
    char ch;
    enum {
        SW_START,
        SW_RSP_NUM,
        SW_RSP_STR,
        SW_SPACES_BEFORE_KEY,
        SW_KEY,
        SW_SPACES_BEFORE_FLAGS,     /* 5 */
        SW_FLAGS,
        SW_SPACES_BEFORE_VLEN,
        SW_VLEN,
        SW_RUNTO_VAL,
        SW_VAL,                     /* 10 */
        SW_VAL_LF,
        SW_END,
        SW_RUNTO_CRLF,
        SW_CRLF,
        SW_ALMOST_DONE,             /* 15 */
        SW_SENTINEL
    } state;

    state = r->state;

    assert(state >= SW_START && state < SW_SENTINEL);

    /* validate the parsing marker */
    assert(r->buf != NULL);
    assert(r->pos < r->len);

    for (p = r->buf+r->pos; p <= r->buf+r->len; p++) {
        ch = *p;

        switch (state) {
        case SW_START:
            if (isdigit(ch)) {
                state = SW_RSP_NUM;
            } else {
                state = SW_RSP_STR;
            }
            p = p - 1; /* go back by 1 byte */

            break;

        case SW_RSP_NUM:
            if (r->token == NULL) {
                /* rsp_start <- p; type_start <- p */
                r->token = p;
            }

            if (isdigit(ch)) {
                /* num <- num * 10 + (ch - '0') */
                r->integer = r->integer*10 + (long long)(ch-'0');
            } else if (ch == ' ' || ch == '\r') {
                /* type_end <- p - 1 */
                r->token = NULL;
                r->integer = 0;
                r->type = RSP_TYPE_NUM;
                p = p - 1; /* go back by 1 byte */
                state = SW_CRLF;
            } else {
                goto error;
            }

            break;

        case SW_RSP_STR:
            if (r->token == NULL) {
                /* rsp_start <- p; type_start <- p */
                r->token = p;
            }

            if (ch == ' ' || ch == '\r') {
                /* type_end <- p - 1 */
                m = r->token;
                /* r->token = NULL; */
                r->type = RSP_TYPE_UNKNOWN;
                assert(r->str == NULL && r->strlen == 0);
                
                switch (p - m) {
                case 3:
                    if (!strncmp(m,"END\r",4)) {
                        r->type = RSP_TYPE_END;
                        /* end_start <- m; end_end <- p - 1 */
                    }

                    break;

                case 5:
                    if (!strncmp(m,"VALUE",5)) {
                        /*
                                           * 
Download .txt
gitextract_y_mdrj8b/

├── .gitignore
├── ChangeLog
├── LICENSE
├── Makefile.am
├── NOTICE
├── README.md
├── conf/
│   └── vire.conf
├── configure.ac
├── dep/
│   ├── .gitignore
│   ├── Makefile.am
│   ├── ae/
│   │   ├── Makefile.am
│   │   ├── ae.c
│   │   ├── ae.h
│   │   ├── ae_epoll.c
│   │   ├── ae_evport.c
│   │   ├── ae_kqueue.c
│   │   └── ae_select.c
│   ├── darray/
│   │   ├── Makefile.am
│   │   ├── darray.c
│   │   └── darray.h
│   ├── dhashkit/
│   │   ├── Makefile.am
│   │   ├── dcrc16.c
│   │   ├── dcrc32.c
│   │   ├── dfnv.c
│   │   ├── dhashkit.h
│   │   ├── dhsieh.c
│   │   ├── djenkins.c
│   │   ├── dketama.c
│   │   ├── dmd5.c
│   │   ├── dmodula.c
│   │   ├── dmurmur.c
│   │   ├── done_at_a_time.c
│   │   ├── drandom.c
│   │   └── dsha1.c
│   ├── dlist/
│   │   ├── Makefile.am
│   │   ├── dlist.c
│   │   ├── dlist.h
│   │   ├── dlockqueue.c
│   │   ├── dlockqueue.h
│   │   ├── dmtqueue.c
│   │   └── dmtqueue.h
│   ├── dmalloc/
│   │   ├── Makefile.am
│   │   ├── dmalloc.c
│   │   └── dmalloc.h
│   ├── himemcached-0.1.0/
│   │   ├── Makefile.am
│   │   ├── himcdep/
│   │   │   ├── sds.c
│   │   │   └── sds.h
│   │   ├── himcread.c
│   │   ├── himcread.h
│   │   ├── himemcached.c
│   │   └── himemcached.h
│   ├── hiredis-0.13.3/
│   │   └── .gitignore
│   ├── jemalloc-4.2.0/
│   │   └── .gitignore
│   ├── jemalloc-4.2.0.tar.bz2
│   ├── sds/
│   │   ├── Makefile.am
│   │   ├── sds.c
│   │   ├── sds.h
│   │   └── sdsalloc.h
│   └── util/
│       ├── Makefile.am
│       ├── dlog.c
│       ├── dlog.h
│       ├── dspecialconfig.h
│       ├── dutil.c
│       └── dutil.h
├── m4/
│   └── .gitignore
├── notes/
│   ├── c-styleguide.txt
│   ├── debug.txt
│   └── socket.txt
├── scripts/
│   └── .gitignore
├── src/
│   ├── Makefile.am
│   ├── vr.c
│   ├── vr_aof.c
│   ├── vr_aof.h
│   ├── vr_backend.c
│   ├── vr_backend.h
│   ├── vr_bitops.c
│   ├── vr_bitops.h
│   ├── vr_block.c
│   ├── vr_block.h
│   ├── vr_client.c
│   ├── vr_client.h
│   ├── vr_command.c
│   ├── vr_command.h
│   ├── vr_conf.c
│   ├── vr_conf.h
│   ├── vr_connection.c
│   ├── vr_connection.h
│   ├── vr_core.c
│   ├── vr_core.h
│   ├── vr_db.c
│   ├── vr_db.h
│   ├── vr_dict.c
│   ├── vr_dict.h
│   ├── vr_eventloop.c
│   ├── vr_eventloop.h
│   ├── vr_hyperloglog.c
│   ├── vr_hyperloglog.h
│   ├── vr_intset.c
│   ├── vr_intset.h
│   ├── vr_listen.c
│   ├── vr_listen.h
│   ├── vr_lzf.h
│   ├── vr_lzfP.h
│   ├── vr_lzf_c.c
│   ├── vr_lzf_d.c
│   ├── vr_master.c
│   ├── vr_master.h
│   ├── vr_multi.c
│   ├── vr_multi.h
│   ├── vr_notify.c
│   ├── vr_notify.h
│   ├── vr_object.c
│   ├── vr_object.h
│   ├── vr_pubsub.c
│   ├── vr_pubsub.h
│   ├── vr_quicklist.c
│   ├── vr_quicklist.h
│   ├── vr_rbtree.c
│   ├── vr_rbtree.h
│   ├── vr_rdb.c
│   ├── vr_rdb.h
│   ├── vr_replication.c
│   ├── vr_replication.h
│   ├── vr_scripting.c
│   ├── vr_scripting.h
│   ├── vr_server.c
│   ├── vr_server.h
│   ├── vr_signal.c
│   ├── vr_signal.h
│   ├── vr_slowlog.c
│   ├── vr_slowlog.h
│   ├── vr_stats.c
│   ├── vr_stats.h
│   ├── vr_t_hash.c
│   ├── vr_t_hash.h
│   ├── vr_t_list.c
│   ├── vr_t_list.h
│   ├── vr_t_set.c
│   ├── vr_t_set.h
│   ├── vr_t_string.c
│   ├── vr_t_string.h
│   ├── vr_t_zset.c
│   ├── vr_t_zset.h
│   ├── vr_thread.c
│   ├── vr_thread.h
│   ├── vr_util.c
│   ├── vr_util.h
│   ├── vr_worker.c
│   ├── vr_worker.h
│   ├── vr_ziplist.c
│   ├── vr_ziplist.h
│   ├── vr_zipmap.c
│   └── vr_zipmap.h
├── tests/
│   ├── .gitignore
│   ├── Makefile.am
│   ├── vrabtest.c
│   ├── vrabtest.h
│   ├── vrt_backend.c
│   ├── vrt_backend.h
│   ├── vrt_benchmark.c
│   ├── vrt_check_data.c
│   ├── vrt_check_data.h
│   ├── vrt_dispatch_data.c
│   ├── vrt_dispatch_data.h
│   ├── vrt_produce_data.c
│   ├── vrt_produce_data.h
│   ├── vrt_public.c
│   ├── vrt_public.h
│   ├── vrt_simple.c
│   ├── vrt_simple.h
│   ├── vrt_util.c
│   ├── vrt_util.h
│   └── vrtest.c
└── tools/
    └── .gitignore
Download .txt
SYMBOL INDEX (1779 symbols across 128 files)

FILE: dep/ae/ae.c
  function aeEventLoop (line 67) | aeEventLoop *aeCreateEventLoop(int setsize) {
  function aeGetSetSize (line 100) | int aeGetSetSize(aeEventLoop *eventLoop) {
  function aeResizeSetSize (line 111) | int aeResizeSetSize(aeEventLoop *eventLoop, int setsize) {
  function aeDeleteEventLoop (line 129) | void aeDeleteEventLoop(aeEventLoop *eventLoop) {
  function aeStop (line 136) | void aeStop(aeEventLoop *eventLoop) {
  function aeCreateFileEvent (line 140) | int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask,
  function aeDeleteFileEvent (line 161) | void aeDeleteFileEvent(aeEventLoop *eventLoop, int fd, int mask)
  function aeGetFileEvents (line 179) | int aeGetFileEvents(aeEventLoop *eventLoop, int fd) {
  function aeGetTime (line 186) | static void aeGetTime(long *seconds, long *milliseconds)
  function aeAddMillisecondsToNow (line 195) | static void aeAddMillisecondsToNow(long long milliseconds, long *sec, lo...
  function aeCreateTimeEvent (line 209) | long long aeCreateTimeEvent(aeEventLoop *eventLoop, long long milliseconds,
  function aeDeleteTimeEvent (line 228) | int aeDeleteTimeEvent(aeEventLoop *eventLoop, long long id)
  function aeTimeEvent (line 252) | static aeTimeEvent *aeSearchNearestTimer(aeEventLoop *eventLoop)
  function processTimeEvents (line 268) | static int processTimeEvents(aeEventLoop *eventLoop) {
  function aeProcessEvents (line 355) | int aeProcessEvents(aeEventLoop *eventLoop, int flags)
  function aeWait (line 436) | int aeWait(int fd, int mask, long long milliseconds) {
  function aeMain (line 456) | void aeMain(aeEventLoop *eventLoop) {
  function aeSetBeforeSleepProc (line 469) | void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *bef...

FILE: dep/ae/ae.h
  type aeEventLoop (line 56) | struct aeEventLoop
  type aeEventLoop (line 59) | struct aeEventLoop
  type aeEventLoop (line 60) | struct aeEventLoop
  type aeEventLoop (line 61) | struct aeEventLoop
  type aeEventLoop (line 62) | struct aeEventLoop
  type aeFileEvent (line 65) | typedef struct aeFileEvent {
  type aeTimeEvent (line 73) | typedef struct aeTimeEvent {
  type aeFiredEvent (line 84) | typedef struct aeFiredEvent {
  type aeEventLoop (line 90) | typedef struct aeEventLoop {

FILE: dep/ae/ae_epoll.c
  type aeApiState (line 34) | typedef struct aeApiState {
  function aeApiCreate (line 39) | static int aeApiCreate(aeEventLoop *eventLoop) {
  function aeApiResize (line 58) | static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
  function aeApiFree (line 65) | static void aeApiFree(aeEventLoop *eventLoop) {
  function aeApiAddEvent (line 73) | static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
  function aeApiDelEvent (line 90) | static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int delmask) {
  function aeApiPoll (line 108) | static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) {

FILE: dep/ae/ae_evport.c
  type aeApiState (line 68) | typedef struct aeApiState {
  function aeApiCreate (line 75) | static int aeApiCreate(aeEventLoop *eventLoop) {
  function aeApiResize (line 97) | static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
  function aeApiFree (line 102) | static void aeApiFree(aeEventLoop *eventLoop) {
  function aeApiLookupPending (line 109) | static int aeApiLookupPending(aeApiState *state, int fd) {
  function aeApiAssociate (line 123) | static int aeApiAssociate(const char *where, int portfd, int fd, int mas...
  function aeApiAddEvent (line 152) | static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
  function aeApiDelEvent (line 183) | static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int mask) {
  function aeApiPoll (line 243) | static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) {

FILE: dep/ae/ae_kqueue.c
  type aeApiState (line 36) | typedef struct aeApiState {
  function aeApiCreate (line 41) | static int aeApiCreate(aeEventLoop *eventLoop) {
  function aeApiResize (line 60) | static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
  function aeApiFree (line 67) | static void aeApiFree(aeEventLoop *eventLoop) {
  function aeApiAddEvent (line 75) | static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
  function aeApiDelEvent (line 90) | static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int mask) {
  function aeApiPoll (line 104) | static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) {

FILE: dep/ae/ae_select.c
  type aeApiState (line 34) | typedef struct aeApiState {
  function aeApiCreate (line 41) | static int aeApiCreate(aeEventLoop *eventLoop) {
  function aeApiResize (line 51) | static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
  function aeApiFree (line 57) | static void aeApiFree(aeEventLoop *eventLoop) {
  function aeApiAddEvent (line 61) | static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
  function aeApiDelEvent (line 69) | static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int mask) {
  function aeApiPoll (line 76) | static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) {

FILE: dep/darray/darray.c
  function darray (line 7) | darray *
  function darray_destroy (line 30) | void
  function darray_init (line 37) | int
  function darray_deinit (line 52) | void
  function darray_idx (line 60) | unsigned long long
  function darray_swap (line 127) | void
  function darray_sort (line 141) | void
  function darray_each (line 151) | int

FILE: dep/darray/darray.h
  type darray (line 7) | typedef struct darray {
  function darray_null (line 16) | static inline void
  function darray_set (line 25) | static inline void
  function darray_n (line 34) | static inline unsigned long long

FILE: dep/dhashkit/dcrc16.c
  function hash_crc16 (line 38) | uint32_t

FILE: dep/dhashkit/dcrc32.c
  function hash_crc32 (line 74) | uint32_t
  function hash_crc32a (line 87) | uint32_t

FILE: dep/dhashkit/dfnv.c
  function hash_fnv1_64 (line 8) | uint32_t
  function hash_fnv1a_64 (line 22) | uint32_t
  function hash_fnv1_32 (line 37) | uint32_t
  function hash_fnv1a_32 (line 52) | uint32_t

FILE: dep/dhashkit/dhashkit.h
  type continuum (line 9) | struct continuum {
  type hash_type_t (line 34) | typedef enum hash_type {
  type dist_type_t (line 41) | typedef enum dist_type {
  type continuum (line 61) | struct continuum
  type continuum (line 62) | struct continuum
  type continuum (line 63) | struct continuum
  type SHA1_CTX (line 67) | typedef struct {

FILE: dep/dhashkit/dhsieh.c
  function hash_hsieh (line 13) | uint32_t

FILE: dep/dhashkit/djenkins.c
  function hash_jenkins (line 46) | uint32_t

FILE: dep/dhashkit/dketama.c
  function ketama_hash (line 11) | static uint32_t
  function ketama_item_cmp (line 24) | static int
  function ketama_dispatch (line 38) | uint32_t

FILE: dep/dhashkit/dmd5.c
  type MD5_u32plus (line 14) | typedef unsigned int MD5_u32plus;
  type MD5_CTX (line 16) | typedef struct {
  function MD5_Init (line 179) | void
  function MD5_Update (line 191) | void
  function MD5_Final (line 227) | void
  function md5_signature (line 283) | void
  function hash_md5 (line 293) | uint32_t

FILE: dep/dhashkit/dmodula.c
  function modula_dispatch (line 9) | uint32_t

FILE: dep/dhashkit/dmurmur.c
  function hash_murmur (line 20) | uint32_t

FILE: dep/dhashkit/done_at_a_time.c
  function hash_one_at_a_time (line 17) | uint32_t

FILE: dep/dhashkit/drandom.c
  function random_dispatch (line 9) | uint32_t

FILE: dep/dhashkit/dsha1.c
  function SHA1Transform (line 53) | void SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
  function SHA1Init (line 114) | void SHA1Init(SHA1_CTX* context)
  function SHA1Update (line 128) | void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len)
  function SHA1Final (line 152) | void SHA1Final(unsigned char digest[20], SHA1_CTX* context)

FILE: dep/dlist/dlist.c
  function dlist (line 12) | dlist *dlistCreate(void)
  function dlistRelease (line 29) | void dlistRelease(dlist *list)
  function dlist (line 51) | dlist *dlistAddNodeHead(dlist *list, void *value)
  function dlist (line 77) | dlist *dlistAddNodeTail(dlist *list, void *value)
  function dlist (line 97) | dlist *dlistInsertNode(dlist *list, dlistNode *old_node, void *value, in...
  function dlistDelNode (line 130) | void dlistDelNode(dlist *list, dlistNode *node)
  function dlistIter (line 149) | dlistIter *dlistGetIterator(dlist *list, int direction)
  function dlistReleaseIterator (line 163) | void dlistReleaseIterator(dlistIter *iter) {
  function dlistRewind (line 168) | void dlistRewind(dlist *list, dlistIter *li) {
  function dlistRewindTail (line 173) | void dlistRewindTail(dlist *list, dlistIter *li) {
  function dlistNode (line 192) | dlistNode *dlistNext(dlistIter *iter)
  function dlist (line 213) | dlist *dlistDup(dlist *orig)
  function dlistNode (line 253) | dlistNode *dlistSearchKey(dlist *list, void *key)
  function dlistNode (line 278) | dlistNode *dlistIndex(dlist *list, long index) {
  function dlistRotate (line 293) | void dlistRotate(dlist *list) {
  function dlist (line 308) | dlist *dlistPush(dlist *list, void *value) {

FILE: dep/dlist/dlist.h
  type dlistNode (line 6) | typedef struct dlistNode {
  type dlistIter (line 12) | typedef struct dlistIter {
  type dlist (line 17) | typedef struct dlist {

FILE: dep/dlist/dlockqueue.c
  function dlockqueue (line 11) | dlockqueue *dlockqueue_create(void)
  function dlockqueue_push (line 33) | long long dlockqueue_push(void *q, void *value)
  function dlockqueue_destroy (line 101) | void dlockqueue_destroy(void *q)
  function dlockqueue_length (line 117) | long long dlockqueue_length(void *q)

FILE: dep/dlist/dlockqueue.h
  type dlist (line 4) | struct dlist
  type dlockqueue (line 6) | typedef struct dlockqueue{

FILE: dep/dlist/dmtqueue.c
  function dmtqueue (line 10) | dmtqueue *dmtqueue_create(void)
  function dmtqueue_destroy (line 28) | void dmtqueue_destroy(dmtqueue *q)
  function dmtqueue_push (line 41) | long long dmtqueue_push(dmtqueue *q, void *value)
  function dmtqueue_empty (line 63) | int dmtqueue_empty(dmtqueue *q)
  function dmtqueue_length (line 79) | long long dmtqueue_length(dmtqueue *q)
  function dmtqueue_init_with_lockqueue (line 96) | int dmtqueue_init_with_lockqueue(dmtqueue *q, dlockqueue_freefunc freefunc)

FILE: dep/dlist/dmtqueue.h
  type dmtqueue (line 9) | typedef struct dmtqueue{

FILE: dep/dmalloc/dmalloc.c
  function dmalloc_size (line 68) | size_t dmalloc_size(void *ptr) {
  function _dfree (line 175) | void
  function dalloc_used_memory (line 206) | size_t
  function dalloc_get_memory_size (line 235) | size_t dalloc_get_memory_size(void) {
  function dalloc_get_rss (line 293) | size_t dalloc_get_rss(void) {
  function dalloc_get_rss (line 333) | size_t dalloc_get_rss(void) {
  function dalloc_get_rss (line 345) | size_t dalloc_get_rss(void) {
  function dalloc_get_fragmentation_ratio (line 356) | float dalloc_get_fragmentation_ratio(size_t rss) {

FILE: dep/himemcached-0.1.0/himcdep/sds.c
  function sds (line 51) | sds sdsnewlen(const void *init, size_t initlen) {
  function sds (line 70) | sds sdsempty(void) {
  function sds (line 75) | sds sdsnew(const char *init) {
  function sds (line 81) | sds sdsdup(const sds s) {
  function sdsfree (line 86) | void sdsfree(sds s) {
  function sdsupdatelen (line 105) | void sdsupdatelen(sds s) {
  function sdsclear (line 116) | void sdsclear(sds s) {
  function sds (line 129) | sds sdsMakeRoomFor(sds s, size_t addlen) {
  function sds (line 155) | sds sdsRemoveFreeSpace(sds s) {
  function sdsAllocSize (line 171) | size_t sdsAllocSize(sds s) {
  function sdsIncrLen (line 200) | void sdsIncrLen(sds s, int incr) {
  function sds (line 215) | sds sdsgrowzero(sds s, size_t len) {
  function sds (line 237) | sds sdscatlen(sds s, const void *t, size_t len) {
  function sds (line 255) | sds sdscat(sds s, const char *t) {
  function sds (line 263) | sds sdscatsds(sds s, const sds t) {
  function sds (line 269) | sds sdscpylen(sds s, const char *t, size_t len) {
  function sds (line 288) | sds sdscpy(sds s, const char *t) {
  function sdsll2str (line 299) | int sdsll2str(char *s, long long value) {
  function sdsull2str (line 331) | int sdsull2str(char *s, unsigned long long v) {
  function sds (line 360) | sds sdscatvprintf(sds s, const char *fmt, va_list ap) {
  function sds (line 399) | sds sdscatprintf(sds s, const char *fmt, ...) {
  function sds (line 425) | sds sdscatfmt(sds s, char const *fmt, ...) {
  function sdstrim (line 543) | void sdstrim(sds s, const char *cset) {
  function sdsrange (line 575) | void sdsrange(sds s, int start, int end) {
  function sdstolower (line 606) | void sdstolower(sds s) {
  function sdstoupper (line 613) | void sdstoupper(sds s) {
  function sdscmp (line 630) | int sdscmp(const sds s1, const sds s2) {
  function sds (line 658) | sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, in...
  function sdsfreesplitres (line 708) | void sdsfreesplitres(sds *tokens, int count) {
  function sds (line 719) | sds sdsfromlonglong(long long value) {
  function sds (line 740) | sds sdscatrepr(sds s, const char *p, size_t len) {
  function is_hex_digit (line 767) | int is_hex_digit(char c) {
  function hex_digit_to_int (line 774) | int hex_digit_to_int(char c) {
  function sds (line 815) | sds *sdssplitargs(const char *line, int *argc) {
  function sds (line 934) | sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen) {
  function sds (line 950) | sds sdsjoin(char **argv, int argc, char *sep, size_t seplen) {
  function sds (line 962) | sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen) {
  function main (line 977) | int main(void) {

FILE: dep/himemcached-0.1.0/himcdep/sds.h
  type sdshdr (line 44) | struct sdshdr {
  function sdslen (line 50) | static inline size_t sdslen(const sds s) {
  function sdsavail (line 55) | static inline size_t sdsavail(const sds s) {

FILE: dep/himemcached-0.1.0/himcread.c
  function __memcachedReaderSetError (line 32) | static void __memcachedReaderSetError(mcReader *r, int type, const char ...
  function chrtos (line 52) | static size_t chrtos(char *buf, size_t size, char byte)
  function __memcachedReaderSetErrorProtocolByte (line 77) | static void __memcachedReaderSetErrorProtocolByte(mcReader *r, char byte) {
  function __memcachedReaderSetErrorOOM (line 86) | static void __memcachedReaderSetErrorOOM(mcReader *r) {
  function elementArrayCreate (line 90) | static int elementArrayCreate(mcReader *r)
  function elementArrayDestroy (line 107) | static void elementArrayDestroy(mcReader *r)
  function elementArrayExpand (line 129) | static int elementArrayExpand(mcReader *r)
  function elementArrayAdd (line 147) | static int elementArrayAdd(mcReader *r, void *reply)
  function memcachedParseResponse (line 159) | static void memcachedParseResponse(mcReader *r)
  function mcReader (line 631) | mcReader *memcachedReaderCreateWithFunctions(mcReplyObjectFunctions *fn)
  function memcachedReaderFree (line 669) | void memcachedReaderFree(mcReader *r)
  function memcachedReaderFeed (line 678) | int memcachedReaderFeed(mcReader *r, const char *buf, size_t len)
  function memcachedReaderReset (line 711) | static void memcachedReaderReset(mcReader *r)
  function memcachedReaderGetReply (line 805) | int memcachedReaderGetReply(mcReader *r, void **reply) {

FILE: dep/himemcached-0.1.0/himcread.h
  type mcReplyObjectFunctions (line 33) | typedef struct mcReplyObjectFunctions {
  type mcReader (line 41) | typedef struct mcReader {

FILE: dep/himemcached-0.1.0/himemcached.c
  function mcReply (line 31) | static mcReply *createReplyObject(int type) {
  function freeMcReplyObject (line 43) | void freeMcReplyObject(void *reply) {
  function __memcachedSetError (line 155) | void __memcachedSetError(mcContext *c, int type, const char *str) {
  function memcachedBufferWrite (line 181) | int memcachedBufferWrite(mcContext *c, int *done) {
  function memcachedGetReplyFromReader (line 212) | int memcachedGetReplyFromReader(mcContext *c, void **reply) {
  function memcachedGetReply (line 220) | int memcachedGetReply(mcContext *c, void **reply) {
  function mcReader (line 250) | mcReader *memcachedReaderCreate(void) {
  function mcContext (line 254) | mcContext *memcachedContextInit(void) {
  function memcachedFree (line 278) | void memcachedFree(mcContext *c) {
  function memcachedBufferRead (line 303) | int memcachedBufferRead(mcContext *c) {
  function getRequestTypeFromString (line 331) | static int getRequestTypeFromString(char *str, size_t len)
  function checkCmdValidAndGetTotalLen (line 384) | static int checkCmdValidAndGetTotalLen(int cmdtype, int argtype, int arg...
  function genericMemcachedCommand (line 463) | static int genericMemcachedCommand(int cmdtype, char *cmd, int argtype, ...
  function memcachedFormatCommandSdsArgv (line 512) | int memcachedFormatCommandSdsArgv(char **target, int argc, const sds *ar...
  function memcachedvFormatCommand (line 552) | int memcachedvFormatCommand(char **target, const char *format, va_list ap)
  function memcachedFormatCommand (line 784) | int memcachedFormatCommand(char **target, const char *format, ...) {
  function memcachedFormatCommandArgv (line 804) | int memcachedFormatCommandArgv(char **target, int argc, const char **arg...

FILE: dep/himemcached-0.1.0/himemcached.h
  type mcReply (line 48) | typedef struct mcReply {
  type mcConnectionType (line 66) | enum mcConnectionType {
  type mcContext (line 72) | typedef struct mcContext {

FILE: dep/sds/sds.c
  function sdsHdrSize (line 42) | static inline int sdsHdrSize(char type) {
  function sdsReqType (line 58) | static inline char sdsReqType(size_t string_size) {
  function sds (line 82) | sds sdsnewlen(const void *init, size_t initlen) {
  function sds (line 140) | sds sdsempty(void) {
  function sds (line 145) | sds sdsnew(const char *init) {
  function sds (line 151) | sds sdsdup(const sds s) {
  function sdsfree (line 156) | void sdsfree(sds s) {
  function sdsupdatelen (line 175) | void sdsupdatelen(sds s) {
  function sdsclear (line 184) | void sdsclear(sds s) {
  function sds (line 195) | sds sdsMakeRoomFor(sds s, size_t addlen) {
  function sds (line 246) | sds sdsRemoveFreeSpace(sds s) {
  function sdsAllocSize (line 279) | size_t sdsAllocSize(sds s) {
  function sdsIncrLen (line 313) | void sdsIncrLen(sds s, int incr) {
  function sds (line 359) | sds sdsgrowzero(sds s, size_t len) {
  function sds (line 377) | sds sdscatlen(sds s, const void *t, size_t len) {
  function sds (line 392) | sds sdscat(sds s, const char *t) {
  function sds (line 400) | sds sdscatsds(sds s, const sds t) {
  function sds (line 406) | sds sdscpylen(sds s, const char *t, size_t len) {
  function sds (line 419) | sds sdscpy(sds s, const char *t) {
  function sdsll2str (line 430) | int sdsll2str(char *s, long long value) {
  function sdsull2str (line 462) | int sdsull2str(char *s, unsigned long long v) {
  function sds (line 494) | sds sdsfromlonglong(long long value) {
  function sds (line 502) | sds sdscatvprintf(sds s, const char *fmt, va_list ap) {
  function sds (line 555) | sds sdscatprintf(sds s, const char *fmt, ...) {
  function sds (line 580) | sds sdscatfmt(sds s, char const *fmt, ...) {
  function sds (line 684) | sds sdstrim(sds s, const char *cset) {
  function sdsrange (line 715) | void sdsrange(sds s, int start, int end) {
  function sdstolower (line 744) | void sdstolower(sds s) {
  function sdstoupper (line 751) | void sdstoupper(sds s) {
  function sdscmp (line 768) | int sdscmp(const sds s1, const sds s2) {
  function sds (line 796) | sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, in...
  function sdsfreesplitres (line 846) | void sdsfreesplitres(sds *tokens, int count) {
  function sds (line 859) | sds sdscatrepr(sds s, const char *p, size_t len) {
  function is_hex_digit (line 886) | int is_hex_digit(char c) {
  function hex_digit_to_int (line 893) | int hex_digit_to_int(char c) {
  function sds (line 934) | sds *sdssplitargs(const char *line, int *argc) {
  function sds (line 1053) | sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen) {
  function sds (line 1069) | sds sdsjoin(char **argv, int argc, char *sep) {
  function sds (line 1081) | sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen) {
  function sdsIsNum (line 1092) | int sdsIsNum(sds s) {
  function sds_free (line 1115) | void sds_free(void *ptr) { s_free(ptr); }
  function sdsTest (line 1123) | int sdsTest(void) {
  function main (line 1288) | int main(void) {

FILE: dep/sds/sds.h
  type sdshdr5 (line 46) | struct __attribute__ ((__packed__)) sdshdr5 {
  type sdshdr8 (line 50) | struct __attribute__ ((__packed__)) sdshdr8 {
  type sdshdr16 (line 56) | struct __attribute__ ((__packed__)) sdshdr16 {
  type sdshdr32 (line 62) | struct __attribute__ ((__packed__)) sdshdr32 {
  type sdshdr64 (line 68) | struct __attribute__ ((__packed__)) sdshdr64 {
  function sdslen (line 86) | static inline size_t sdslen(const sds s) {
  function sdsavail (line 103) | static inline size_t sdsavail(const sds s) {
  function sdssetlen (line 129) | static inline void sdssetlen(sds s, size_t newlen) {
  function sdsinclen (line 153) | static inline void sdsinclen(sds s, size_t inc) {
  function sdsalloc (line 179) | static inline size_t sdsalloc(const sds s) {
  function sdssetalloc (line 196) | static inline void sdssetalloc(sds s, size_t newlen) {

FILE: dep/util/dlog.c
  type logger (line 13) | struct logger
  function log_init (line 15) | int
  function log_deinit (line 36) | void
  function log_reopen (line 48) | void
  function log_level_up (line 63) | void
  function log_level_down (line 74) | void
  function log_level_set (line 85) | void
  function log_stacktrace (line 94) | void
  function log_loggable (line 105) | int
  function _log (line 117) | void
  function _log_stderr (line 159) | void
  function _log_stdout (line 186) | void
  function _log_hexdump (line 217) | void
  function _log_safe (line 285) | void
  function _log_stderr_safe (line 318) | void
  function log_write_len (line 347) | void log_write_len(char *str, size_t len)

FILE: dep/util/dlog.h
  type logger (line 8) | struct logger {

FILE: dep/util/dutil.c
  function dassert (line 37) | void
  function dstacktrace (line 48) | void
  function dstacktrace_fd (line 72) | void
  function _dvscnprintf (line 84) | int
  function _dscnprintf (line 112) | int
  function _safe_vsnprintf (line 208) | int
  function _safe_snprintf (line 289) | int
  function dusec_now (line 303) | long long
  function dmsec_now (line 324) | long long
  function dsec_now (line 333) | long long
  function string_match_len (line 340) | int string_match_len(const char *pattern, int patternLen,
  function string_match (line 462) | int string_match(const char *pattern, const char *string, int nocase) {

FILE: src/vr.c
  type option (line 34) | struct option
  function rstatus_t (line 49) | static rstatus_t
  function vr_print_run (line 151) | static void
  function vr_print_done (line 201) | static void
  function vr_show_usage (line 207) | static void
  function rstatus_t (line 235) | static rstatus_t
  function vr_remove_pidfile (line 264) | static void
  function vr_set_default_options (line 276) | static void
  function rstatus_t (line 300) | static rstatus_t
  function vr_test_conf (line 397) | static bool
  function vr_pre_run (line 418) | static int
  function vr_post_run (line 466) | static void
  function vr_run (line 485) | static void
  function main (line 506) | int

FILE: src/vr_aof.c
  function aofRewriteBufferSize (line 4) | unsigned long aofRewriteBufferSize(void) {
  function sds (line 24) | sds catAppendOnlyExpireAtCommand(sds buf, struct redisCommand *cmd, robj...
  function sds (line 54) | sds catAppendOnlyGenericCommand(sds dst, int argc, robj **argv) {
  function aofChildWriteDiffData (line 82) | void aofChildWriteDiffData(aeEventLoop *el, int fd, void *privdata, int ...
  function aofRewriteBufferAppend (line 111) | void aofRewriteBufferAppend(unsigned char *s, unsigned long len) {
  function feedAppendOnlyFile (line 157) | void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **arg...

FILE: src/vr_aof.h
  type aofrwblock (line 27) | typedef struct aofrwblock {
  type redisCommand (line 34) | struct redisCommand
  type redisCommand (line 37) | struct redisCommand

FILE: src/vr_backend.c
  type darray (line 6) | struct darray
  function vr_backend_init (line 10) | int
  function vr_backend_deinit (line 34) | void
  function backend_cron (line 44) | static int
  function setup_backend (line 77) | static int
  function backends_init (line 101) | int
  function backends_run (line 125) | int
  function backends_wait (line 141) | int
  function backends_deinit (line 157) | void

FILE: src/vr_backend.h
  type vr_backend (line 4) | typedef struct vr_backend {
  type darray (line 22) | struct darray

FILE: src/vr_bitops.c
  function redisPopcount (line 10) | size_t redisPopcount(void *s, long count) {
  function redisBitpos (line 71) | long redisBitpos(void *s, unsigned long count, int bit) {
  function setUnsignedBitfield (line 172) | void setUnsignedBitfield(unsigned char *p, uint64_t offset, uint64_t bit...
  function setSignedBitfield (line 187) | void setSignedBitfield(unsigned char *p, uint64_t offset, uint64_t bits,...
  function getUnsignedBitfield (line 197) | uint64_t getUnsignedBitfield(unsigned char *p, uint64_t offset, uint64_t...
  function getSignedBitfield (line 211) | int64_t getSignedBitfield(unsigned char *p, uint64_t offset, uint64_t bi...
  function checkUnsignedBitfieldOverflow (line 244) | int checkUnsignedBitfieldOverflow(uint64_t value, int64_t incr, uint64_t...
  function checkSignedBitfieldOverflow (line 281) | int checkSignedBitfieldOverflow(int64_t value, int64_t incr, uint64_t bi...
  function printBits (line 335) | void printBits(unsigned char *p, unsigned long count) {
  function getBitOffsetFromArgument (line 367) | int getBitOffsetFromArgument(client *c, robj *o, size_t *offset, int has...
  function getBitfieldTypeFromArgument (line 403) | int getBitfieldTypeFromArgument(client *c, robj *o, int *sign, int *bits) {
  function robj (line 434) | robj *lookupStringForBitCommand(client *c, size_t maxbit, int *expired) {
  function setbitCommand (line 450) | void setbitCommand(client *c) {
  function getbitCommand (line 498) | void getbitCommand(client *c) {
  function bitopCommand (line 535) | void bitopCommand(client *c) {
  function bitcountCommand (line 709) | void bitcountCommand(client *c) {
  function bitposCommand (line 782) | void bitposCommand(client *c) {
  type bitfieldOp (line 898) | struct bitfieldOp {
  function bitfieldCommand (line 907) | void bitfieldCommand(client *c) {

FILE: src/vr_bitops.h
  type client (line 13) | struct client
  type client (line 14) | struct client
  type client (line 15) | struct client
  type client (line 16) | struct client
  type client (line 17) | struct client
  type client (line 18) | struct client
  type client (line 19) | struct client
  type client (line 20) | struct client

FILE: src/vr_block.c
  function unblockClient (line 6) | void unblockClient(client *c) {
  function getTimeoutFromObjectOrReply (line 35) | int getTimeoutFromObjectOrReply(client *c, robj *object, long long *time...
  function blockClient (line 59) | void blockClient(client *c, int btype) {

FILE: src/vr_block.h
  type blockingState (line 6) | typedef struct blockingState {
  type client (line 22) | struct client
  type client (line 23) | struct client
  type client (line 24) | struct client

FILE: src/vr_client.c
  function sdsZmallocSize (line 10) | size_t sdsZmallocSize(sds s) {
  function freeClientReplyValue (line 19) | void freeClientReplyValue(void *o) {
  function listMatchObjects (line 23) | int listMatchObjects(void *a, void *b) {
  function client (line 27) | client *createClient(vr_eventloop *vel, struct conn *conn) {
  function prepareClientToWrite (line 123) | int prepareClientToWrite(client *c) {
  function robj (line 163) | robj *dupLastObjectIfNeeded(dlist *reply) {
  function _addReplyToBuffer (line 180) | int _addReplyToBuffer(client *c, const char *s, size_t len) {
  function _addReplyObjectToList (line 197) | void _addReplyObjectToList(client *c, robj *o) {
  function _addReplySdsToList (line 235) | void _addReplySdsToList(client *c, sds s) {
  function _addReplyStringToList (line 266) | void _addReplyStringToList(client *c, const char *s, size_t len) {
  function addReply (line 302) | void addReply(client *c, robj *obj) {
  function addReplySds (line 339) | void addReplySds(client *c, sds s) {
  function addReplyString (line 353) | void addReplyString(client *c, const char *s, size_t len) {
  function addReplyErrorLength (line 359) | void addReplyErrorLength(client *c, const char *s, size_t len) {
  function addReplyError (line 365) | void addReplyError(client *c, const char *err) {
  function addReplyErrorFormat (line 369) | void addReplyErrorFormat(client *c, const char *fmt, ...) {
  function addReplyStatusLength (line 385) | void addReplyStatusLength(client *c, const char *s, size_t len) {
  function addReplyStatus (line 391) | void addReplyStatus(client *c, const char *status) {
  function addReplyStatusFormat (line 395) | void addReplyStatusFormat(client *c, const char *fmt, ...) {
  function setDeferredMultiBulkLength (line 416) | void setDeferredMultiBulkLength(client *c, void *node, long length) {
  function addReplyDouble (line 443) | void addReplyDouble(client *c, double d) {
  function addReplyHumanLongDouble (line 460) | void addReplyHumanLongDouble(client *c, long double d) {
  function addReplyLongLongWithPrefix (line 468) | void addReplyLongLongWithPrefix(client *c, long long ll, char prefix) {
  function addReplyLongLong (line 490) | void addReplyLongLong(client *c, long long ll) {
  function addReplyMultiBulkLen (line 499) | void addReplyMultiBulkLen(client *c, long length) {
  function addReplyBulkLen (line 507) | void addReplyBulkLen(client *c, robj *obj) {
  function addReplyBulk (line 533) | void addReplyBulk(client *c, robj *obj) {
  function addReplyBulkCBuffer (line 540) | void addReplyBulkCBuffer(client *c, const void *p, size_t len) {
  function addReplyBulkSds (line 547) | void addReplyBulkSds(client *c, sds s)  {
  function addReplyBulkCString (line 555) | void addReplyBulkCString(client *c, const char *s) {
  function addReplyBulkLongLong (line 564) | void addReplyBulkLongLong(client *c, long long ll) {
  function copyClientOutputBuffer (line 575) | void copyClientOutputBuffer(client *dst, client *src) {
  function clientHasPendingReplies (line 585) | int clientHasPendingReplies(client *c) {
  function freeClientArgv (line 589) | static void freeClientArgv(client *c) {
  function disconnectSlaves (line 600) | void disconnectSlaves(void) {
  function unlinkClientFromEventloop (line 610) | void unlinkClientFromEventloop(client *c) {
  function linkClientToEventloop (line 653) | void linkClientToEventloop(client *c,vr_eventloop *vel) {
  function unlinkClient (line 682) | void unlinkClient(client *c) {
  function freeClient (line 722) | void freeClient(client *c) {
  function freeClientAsync (line 819) | void freeClientAsync(client *c) {
  function freeClientsInAsyncFreeQueue (line 825) | void freeClientsInAsyncFreeQueue(vr_eventloop *vel) {
  function writeToClient (line 838) | int writeToClient(int fd, client *c, int handler_installed) {
  function sendReplyToClient (line 926) | void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) {
  function handleClientsWithPendingWrites (line 936) | int handleClientsWithPendingWrites(vr_eventloop *vel) {
  function resetClient (line 963) | void resetClient(client *c) {
  function processInlineBuffer (line 984) | int processInlineBuffer(client *c) {
  function setProtocolError (line 1047) | static void setProtocolError(client *c, int pos) {
  function processMultibulkBuffer (line 1058) | int processMultibulkBuffer(client *c) {
  function processInputBuffer (line 1196) | void processInputBuffer(client *c) {
  function readQueryFromClient (line 1248) | void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int ma...
  function getClientsMaxBuffers (line 1309) | void getClientsMaxBuffers(vr_eventloop *vel, unsigned long *longest_outp...
  function genClientPeerId (line 1338) | void genClientPeerId(client *client, char *peerid,
  function sds (line 1365) | sds catClientInfoString(sds s, client *client) {
  function sds (line 1417) | sds getAllClientsInfoString(vr_eventloop *vel) {
  type clientkilldata (line 1432) | struct clientkilldata {
  function clientCommand (line 1441) | void clientCommand(client *c) {
  function rewriteClientCommandVector (line 1659) | void rewriteClientCommandVector(client *c, int argc, ...) {
  function replaceClientCommandVector (line 1683) | void replaceClientCommandVector(client *c, int argc, robj **argv) {
  function rewriteClientCommandArgument (line 1703) | void rewriteClientCommandArgument(client *c, int i, robj *newval) {
  function getClientOutputBufferMemoryUsage (line 1735) | unsigned long getClientOutputBufferMemoryUsage(client *c) {
  function getClientType (line 1750) | int getClientType(client *c) {
  function getClientTypeByName (line 1758) | int getClientTypeByName(char *name) {
  function checkClientOutputBufferLimits (line 1782) | int checkClientOutputBufferLimits(client *c) {
  function asyncCloseClientOnOutputBufferLimitReached (line 1827) | void asyncCloseClientOnOutputBufferLimitReached(client *c) {
  function flushSlavesOutputBuffers (line 1843) | void flushSlavesOutputBuffers(void) {
  function pauseClients (line 1885) | void pauseClients(vr_eventloop *vel, long long end) {
  function clientsArePaused (line 1895) | int clientsArePaused(vr_eventloop *vel) {
  function processEventsWhileBlocked (line 1933) | int processEventsWhileBlocked(vr_eventloop *vel) {
  function current_clients (line 1946) | int

FILE: src/vr_client.h
  type client (line 69) | typedef struct client {
  type clientBufferLimitsConfig (line 130) | typedef struct clientBufferLimitsConfig {
  type conn (line 137) | struct conn

FILE: src/vr_command.c
  type redisCommand (line 65) | struct redisCommand
  function populateCommandTable (line 184) | void populateCommandTable(void) {
  function populateCommandsNeedAdminpass (line 220) | int populateCommandsNeedAdminpass(void) {
  type redisCommand (line 243) | struct redisCommand
  type redisCommand (line 254) | struct redisCommand
  type redisCommand (line 255) | struct redisCommand
  type redisCommand (line 261) | struct redisCommand
  type redisCommand (line 262) | struct redisCommand
  function call (line 308) | void call(client *c, int flags) {
  function processCommand (line 431) | int processCommand(client *c) {
  function redisOpArrayInit (line 606) | void redisOpArrayInit(redisOpArray *oa) {
  function redisOpArrayAppend (line 611) | int redisOpArrayAppend(redisOpArray *oa, struct redisCommand *cmd, int d...
  function redisOpArrayFree (line 627) | void redisOpArrayFree(redisOpArray *oa) {
  function propagate (line 652) | void propagate(struct redisCommand *cmd, int dbid, robj **argv, int argc,
  function alsoPropagate (line 673) | void alsoPropagate(struct redisCommand *cmd, int dbid, robj **argv, int ...
  function forceCommandPropagation (line 691) | void forceCommandPropagation(client *c, int flags) {
  function preventCommandPropagation (line 699) | void preventCommandPropagation(client *c) {
  function preventCommandAOF (line 704) | void preventCommandAOF(client *c) {
  function preventCommandReplication (line 709) | void preventCommandReplication(client *c) {
  function addReplyCommandFlag (line 714) | static int addReplyCommandFlag(client *c, struct redisCommand *cmd, int ...
  function addReplyCommand (line 723) | static void addReplyCommand(client *c, struct redisCommand *cmd) {
  function commandCommand (line 760) | void commandCommand(client *c) {
  type darray (line 856) | struct darray
  type darray (line 861) | struct darray
  type redisCommand (line 862) | struct redisCommand
  type redisCommand (line 868) | struct redisCommand
  function commandStatsTableDestroy (line 879) | void

FILE: src/vr_command.h
  type client (line 41) | struct client
  type redisCommand (line 42) | struct redisCommand
  type redisCommand (line 43) | struct redisCommand {
  type commandStats (line 60) | typedef struct commandStats {
  type redisOp (line 72) | typedef struct redisOp {
  type redisOpArray (line 85) | typedef struct redisOpArray {
  type redisCommand (line 95) | struct redisCommand
  type redisCommand (line 96) | struct redisCommand
  type redisCommand (line 97) | struct redisCommand
  type client (line 99) | struct client
  type client (line 100) | struct client
  type redisCommand (line 103) | struct redisCommand
  type redisCommand (line 106) | struct redisCommand
  type redisCommand (line 107) | struct redisCommand
  type client (line 108) | struct client
  type client (line 109) | struct client
  type client (line 110) | struct client
  type client (line 111) | struct client
  type client (line 113) | struct client
  type darray (line 115) | struct darray
  type darray (line 116) | struct darray

FILE: src/vr_conf.c
  function conf_value_dump (line 122) | static void
  function conf_organization_dump (line 144) | static void
  function conf_organizations_dump (line 179) | static void
  function conf_set_maxmemory (line 211) | int
  function conf_set_maxmemory_policy (line 245) | int
  function conf_set_int_non_zero (line 289) | int
  function conf_get_sds (line 333) | int
  function conf_set_sds (line 352) | int
  function conf_set_password (line 375) | int
  function conf_get_int (line 403) | int
  function conf_set_int (line 421) | int
  function conf_get_longlong (line 459) | int
  function conf_set_longlong (line 477) | int
  function conf_set_yesorno (line 506) | int
  function conf_set_array_sds (line 539) | int
  function conf_set_commands_need_adminpass (line 586) | int
  function conf_get_array_sds (line 633) | int
  function dictConfValueDestructor (line 662) | static void dictConfValueDestructor(void *privdata, void *val)
  function dictDestructor (line 669) | static void dictDestructor(void *privdata, void *val)
  function conf_value (line 703) | conf_value *conf_value_create(int type)
  function conf_value_destroy (line 726) | void conf_value_destroy(conf_value *cv)
  function conf_server_init (line 757) | static int conf_server_init(conf_server *cs)
  function conf_server_set_default (line 783) | static int conf_server_set_default(conf_server *cs)
  function conf_server_deinit (line 831) | static void conf_server_deinit(conf_server *cs)
  function conf_server_get (line 877) | int
  function conf_server_set (line 889) | int
  function conf_init (line 901) | static int conf_init(vr_conf *cf)
  function conf_set_default (line 927) | static int conf_set_default(vr_conf *cf)
  function conf_deinit (line 935) | static void conf_deinit(vr_conf *cf)
  function conf_server_dump (line 958) | static void
  function conf_dump (line 973) | static void
  function conf_key_value_insert (line 992) | static int
  function conf_pre_load_from_string (line 1033) | static int
  function conf_pre_validate (line 1130) | static int
  function conf_parse_conf_server (line 1165) | static int
  function conf_parse (line 1195) | static int
  function conf_post_validate (line 1241) | static int
  function vr_conf (line 1256) | static vr_conf *
  function vr_conf (line 1306) | vr_conf *
  function conf_destroy (line 1348) | void
  function conf_version_get (line 1360) | unsigned long long
  function CONF_RLOCK (line 1372) | int
  function CONF_WLOCK (line 1378) | int
  function CONF_UNLOCK (line 1384) | int
  function CONFF_LOCK (line 1390) | int
  function CONFF_UNLOCK (line 1396) | int
  function configSetCommand (line 1412) | static void configSetCommand(client *c) {
  function addReplyConfOption (line 1516) | static void addReplyConfOption(client *c,conf_option *cop)
  function configGetCommand (line 1561) | static void configGetCommand(client *c) {
  type rewriteConfigState (line 1600) | struct rewriteConfigState {
  function rewriteConfigAppendLine (line 1610) | static void rewriteConfigAppendLine(struct rewriteConfigState *state, sd...
  function rewriteConfigAddLineNumberToOption (line 1616) | static void rewriteConfigAddLineNumberToOption(struct rewriteConfigState...
  type rewriteConfigState (line 1651) | struct rewriteConfigState
  type rewriteConfigState (line 1653) | struct rewriteConfigState
  function rewriteConfigMarkAsProcessed (line 1712) | static void rewriteConfigMarkAsProcessed(struct rewriteConfigState *stat...
  function rewriteConfigRewriteLine (line 1734) | static void rewriteConfigRewriteLine(struct rewriteConfigState *state, c...
  function rewriteConfigReleaseState (line 1770) | static void rewriteConfigReleaseState(struct rewriteConfigState *state) {
  function rewriteConfigRemoveOrphaned (line 1785) | static void rewriteConfigRemoveOrphaned(struct rewriteConfigState *state) {
  function sds (line 1814) | static sds rewriteConfigGetContentFromState(struct rewriteConfigState *s...
  function rewriteConfigOverwriteFile (line 1844) | static int rewriteConfigOverwriteFile(char *configfile, sds content) {
  function rewriteConfigIntOption (line 1890) | static void rewriteConfigIntOption(struct rewriteConfigState *state, cha...
  function rewriteConfigSdsOption (line 1903) | static void rewriteConfigSdsOption(struct rewriteConfigState *state, cha...
  function rewriteConfigLongLongOption (line 1928) | static void rewriteConfigLongLongOption(struct rewriteConfigState *state...
  function rewriteConfigFormatMemory (line 1942) | static int rewriteConfigFormatMemory(char *buf, size_t len, long long by...
  function rewriteConfigBytesOption (line 1959) | static void rewriteConfigBytesOption(struct rewriteConfigState *state, c...
  function rewriteConfigEnumOption (line 1976) | static void rewriteConfigEnumOption(struct rewriteConfigState *state, ch...
  function rewriteConfigBindOption (line 1990) | static void rewriteConfigBindOption(struct rewriteConfigState *state) {
  function rewriteConfigCommandsNAPOption (line 2019) | void rewriteConfigCommandsNAPOption(struct rewriteConfigState *state) {
  function rewriteConfig (line 2052) | static int rewriteConfig(char *path) {
  function configCommand (line 2103) | void configCommand(client *c) {
  function conf_cache_init (line 2146) | int
  function conf_cache_deinit (line 2160) | int
  function conf_cache_update (line 2176) | int

FILE: src/vr_conf.h
  type conf_option (line 66) | typedef struct conf_option {
  type evictpolicy_type_t (line 84) | typedef enum evictpolicy_type {
  type conf_server (line 90) | typedef struct conf_server {
  type vr_conf (line 118) | typedef struct vr_conf {
  type conf_value (line 134) | typedef struct conf_value{
  type conf_cache (line 141) | typedef struct conf_cache {
  type client (line 192) | struct client

FILE: src/vr_connection.c
  type conn (line 5) | struct conn
  type conn (line 7) | struct conn
  type conn (line 10) | struct conn
  type conn (line 67) | struct conn
  type conn (line 70) | struct conn
  function conn_free (line 82) | static void
  function conn_put (line 118) | void
  function conn_init (line 157) | int
  function conn_deinit (line 175) | void
  function conn_recv (line 189) | ssize_t
  function conn_send (line 239) | ssize_t
  function conn_sendv (line 287) | ssize_t

FILE: src/vr_connection.h
  type conn_base (line 4) | typedef struct conn_base {
  type conn (line 11) | struct conn {
  type conn (line 36) | struct conn
  type conn (line 37) | struct conn
  type conn (line 42) | struct conn
  type conn (line 43) | struct conn
  type conn (line 44) | struct conn
  type darray (line 44) | struct darray

FILE: src/vr_core.h
  type rstatus_t (line 36) | typedef int rstatus_t;
  type err_t (line 37) | typedef int err_t;
  type mstime_t (line 39) | typedef long long mstime_t;
  type instance (line 41) | struct instance
  type darray (line 42) | struct darray
  type conn (line 43) | struct conn
  type client (line 44) | struct client
  type clientBufferLimitsConfig (line 45) | struct clientBufferLimitsConfig
  type redisCommand (line 46) | struct redisCommand
  type vr_worker (line 47) | struct vr_worker
  type instance (line 132) | struct instance {

FILE: src/vr_db.c
  type evictionPoolEntry (line 39) | struct evictionPoolEntry
  type evictionPoolEntry (line 40) | struct evictionPoolEntry
  function redisDbInit (line 55) | int redisDbInit(redisDb *db)
  function redisDbDeinit (line 70) | int
  function lockDbRead (line 77) | int
  function lockDbWrite (line 84) | int
  function unlockDb (line 91) | int
  function robj (line 98) | robj *lookupKey(redisDb *db, robj *key) {
  function robj (line 115) | robj *lookupKeyRead(redisDb *db, robj *key) {
  function robj (line 120) | robj *lookupKeyWrite(redisDb *db, robj *key, int *expired) {
  function robj (line 125) | robj *lookupKeyReadOrReply(client *c, robj *key, robj *reply) {
  function robj (line 131) | robj *lookupKeyWriteOrReply(client *c, robj *key, robj *reply, int *expi...
  function dbAdd (line 142) | void dbAdd(redisDb *db, robj *key, robj *val) {
  function dbOverwrite (line 155) | void dbOverwrite(redisDb *db, robj *key, robj *val) {
  function setKey (line 168) | void setKey(redisDb *db, robj *key, robj *val, int *expired) {
  function dbExists (line 178) | int dbExists(redisDb *db, robj *key) {
  function robj (line 186) | robj *dbRandomKey(redisDb *db) {
  function dbDelete (line 215) | int dbDelete(redisDb *db, robj *key) {
  function robj (line 226) | robj *dbUnshareStringValue(redisDb *db, robj *key, robj *o) {
  function emptyDb (line 239) | long long emptyDb(void(callback)(void*)) {
  function selectDb (line 254) | int selectDb(client *c, int id) {
  function signalModifiedKey (line 273) | void signalModifiedKey(redisDb *db, robj *key) {
  function signalFlushedDb (line 277) | void signalFlushedDb(int dbid) {
  function flushdbCommand (line 285) | void flushdbCommand(client *c) {
  function flushallCommand (line 301) | void flushallCommand(client *c) {
  function delCommand (line 316) | void delCommand(client *c) {
  function existsCommand (line 342) | void existsCommand(client *c) {
  function selectCommand (line 362) | void selectCommand(client *c) {
  function randomkeyCommand (line 376) | void randomkeyCommand(client *c) {
  function keysCommand (line 400) | void keysCommand(client *c) {
  function scanCallback (line 456) | void scanCallback(void *privdata, const dictEntry *de) {
  function parseScanCursorOrReply (line 489) | int parseScanCursorOrReply(client *c, robj *o, unsigned long *cursor) {
  function scanGenericCommand (line 515) | void scanGenericCommand(client *c, int scantype) {
  function scanCommand (line 760) | void scanCommand(client *c) {
  function dbsizeCommand (line 764) | void dbsizeCommand(client *c) {
  function lastsaveCommand (line 778) | void lastsaveCommand(client *c) {
  function typeCommand (line 782) | void typeCommand(client *c) {
  function shutdownCommand (line 811) | void shutdownCommand(client *c) {
  function renameGenericCommand (line 839) | void renameGenericCommand(client *c, int nx) {
  function renameCommand (line 881) | void renameCommand(client *c) {
  function renamenxCommand (line 885) | void renamenxCommand(client *c) {
  function moveCommand (line 889) | void moveCommand(client *c) {
  function removeExpire (line 943) | int removeExpire(redisDb *db, robj *key) {
  function setExpire (line 950) | void setExpire(redisDb *db, robj *key, long long when) {
  function getExpire (line 962) | long long getExpire(redisDb *db, robj *key) {
  function propagateExpire (line 983) | void propagateExpire(redisDb *db, robj *key) {
  function checkIfExpired (line 1000) | int checkIfExpired(redisDb *db, robj *key) {
  function expireIfNeeded (line 1011) | int expireIfNeeded(redisDb *db, robj *key) {
  function expireGenericCommand (line 1057) | void expireGenericCommand(client *c, long long basetime, int unit) {
  function expireCommand (line 1111) | void expireCommand(client *c) {
  function expireatCommand (line 1115) | void expireatCommand(client *c) {
  function pexpireCommand (line 1119) | void pexpireCommand(client *c) {
  function pexpireatCommand (line 1123) | void pexpireatCommand(client *c) {
  function ttlGenericCommand (line 1127) | void ttlGenericCommand(client *c, int output_ms) {
  function ttlCommand (line 1156) | void ttlCommand(client *c) {
  function pttlCommand (line 1160) | void pttlCommand(client *c) {
  function persistCommand (line 1164) | void persistCommand(client *c) {
  type redisCommand (line 1189) | struct redisCommand
  type redisCommand (line 1219) | struct redisCommand
  function getKeysFreeResult (line 1228) | void getKeysFreeResult(int *result) {
  type redisCommand (line 1235) | struct redisCommand
  type redisCommand (line 1264) | struct redisCommand
  type redisCommand (line 1292) | struct redisCommand
  type redisCommand (line 1334) | struct redisCommand
  function fetchInternalDbByKey (line 1361) | int fetchInternalDbByKey(client *c, robj *key) {
  function fetchInternalDbById (line 1366) | int fetchInternalDbById(client *c, int idx) {
  function tryResizeHashTablesForDb (line 1373) | void tryResizeHashTablesForDb(int dbid) {
  function incrementallyRehashForDb (line 1392) | int incrementallyRehashForDb(int dbid) {
  function activeExpireCycle (line 1437) | void activeExpireCycle(vr_backend *backend, int type) {
  function activeExpireCycleTryExpire (line 1568) | int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) {
  function databasesCron (line 1584) | void databasesCron(vr_backend *backend) {

FILE: src/vr_db.h
  type evictionPoolEntry (line 12) | struct evictionPoolEntry {
  type redisDb (line 20) | typedef struct redisDb {
  type client (line 47) | struct client
  type client (line 48) | struct client
  type client (line 57) | struct client
  type client (line 60) | struct client
  type client (line 61) | struct client
  type client (line 62) | struct client
  type client (line 63) | struct client
  type client (line 64) | struct client
  type client (line 65) | struct client
  type client (line 66) | struct client
  type client (line 68) | struct client
  type client (line 69) | struct client
  type client (line 70) | struct client
  type client (line 71) | struct client
  type client (line 72) | struct client
  type client (line 73) | struct client
  type client (line 74) | struct client
  type client (line 75) | struct client
  type client (line 76) | struct client
  type client (line 77) | struct client
  type client (line 78) | struct client
  type client (line 85) | struct client
  type client (line 86) | struct client
  type client (line 87) | struct client
  type client (line 88) | struct client
  type client (line 89) | struct client
  type client (line 90) | struct client
  type client (line 91) | struct client
  type client (line 92) | struct client
  type client (line 93) | struct client
  type redisCommand (line 94) | struct redisCommand
  type redisCommand (line 95) | struct redisCommand
  type redisCommand (line 97) | struct redisCommand
  type redisCommand (line 98) | struct redisCommand
  type redisCommand (line 99) | struct redisCommand
  type redisCommand (line 100) | struct redisCommand
  type client (line 102) | struct client
  type client (line 103) | struct client

FILE: src/vr_dict.c
  function dictIntHashFunction (line 32) | unsigned int dictIntHashFunction(unsigned int key)
  function dictSetHashFunctionSeed (line 45) | void dictSetHashFunctionSeed(uint32_t seed) {
  function dictGetHashFunctionSeed (line 49) | uint32_t dictGetHashFunctionSeed(void) {
  function dictGenHashFunction (line 64) | unsigned int dictGenHashFunction(const void *key, int len) {
  function dictGenCaseHashFunction (line 108) | unsigned int dictGenCaseHashFunction(const unsigned char *buf, int len) {
  function _dictReset (line 120) | static void _dictReset(dictht *ht)
  function dict (line 129) | dict *dictCreate(dictType *type,
  function _dictInit (line 139) | int _dictInit(dict *d, dictType *type,
  function dictResize (line 153) | int dictResize(dict *d)
  function dictExpand (line 165) | int dictExpand(dict *d, unsigned long size)
  function dictRehash (line 206) | int dictRehash(dict *d, int n) {
  function timeInMilliseconds (line 251) | long long timeInMilliseconds(void) {
  function dictRehashMilliseconds (line 259) | int dictRehashMilliseconds(dict *d, int ms) {
  function _dictRehashStep (line 278) | static void _dictRehashStep(dict *d) {
  function dictAdd (line 283) | int dictAdd(dict *d, void *key, void *val)
  function dictEntry (line 307) | dictEntry *dictAddRaw(dict *d, void *key)
  function dictReplace (line 339) | int dictReplace(dict *d, void *key, void *val)
  function dictEntry (line 366) | dictEntry *dictReplaceRaw(dict *d, void *key) {
  function dictGenericDelete (line 373) | static int dictGenericDelete(dict *d, const void *key, int nofree)
  function dictDelete (line 410) | int dictDelete(dict *ht, const void *key) {
  function dictDeleteNoFree (line 414) | int dictDeleteNoFree(dict *ht, const void *key) {
  function _dictClear (line 419) | int _dictClear(dict *d, dictht *ht, void(callback)(void *)) {
  function dictRelease (line 446) | void dictRelease(dict *d)
  function dictEntry (line 453) | dictEntry *dictFind(dict *d, const void *key)
  function dictFingerprint (line 487) | long long dictFingerprint(dict *d) {
  function dictIterator (line 519) | dictIterator *dictGetIterator(dict *d)
  function dictIterator (line 532) | dictIterator *dictGetSafeIterator(dict *d) {
  function dictEntry (line 539) | dictEntry *dictNext(dictIterator *iter)
  function dictReleaseIterator (line 574) | void dictReleaseIterator(dictIterator *iter)
  function dictEntry (line 589) | dictEntry *dictGetRandomKey(dict *d)
  function dictGetSomeKeys (line 652) | unsigned int dictGetSomeKeys(dict *d, dictEntry **des, unsigned int coun...
  function rev (line 721) | static unsigned long rev(unsigned long v) {
  function dictScan (line 815) | unsigned long dictScan(dict *d,
  function _dictExpandIfNeeded (line 889) | static int _dictExpandIfNeeded(dict *d)
  function _dictNextPower (line 911) | static unsigned long _dictNextPower(unsigned long size)
  function _dictKeyIndex (line 929) | static int _dictKeyIndex(dict *d, const void *key)
  function dictEmpty (line 953) | void dictEmpty(dict *d, void(callback)(void*)) {
  function dictEnableResize (line 960) | void dictEnableResize(void) {
  function dictDisableResize (line 964) | void dictDisableResize(void) {
  function _dictGetStatsHt (line 971) | size_t _dictGetStatsHt(char *buf, size_t bufsize, dictht *ht, int tablei...
  function dictGetStats (line 1032) | void dictGetStats(char *buf, size_t bufsize, dict *d) {

FILE: src/vr_dict.h
  type dictEntry (line 12) | typedef struct dictEntry {
  type dictType (line 23) | typedef struct dictType {
  type dictht (line 34) | typedef struct dictht {
  type dict (line 41) | typedef struct dict {
  type dictIterator (line 53) | typedef struct dictIterator {

FILE: src/vr_eventloop.c
  function vr_eventloop_init (line 3) | int
  function vr_eventloop_deinit (line 93) | void

FILE: src/vr_eventloop.h
  type vr_eventloop (line 4) | typedef struct vr_eventloop {

FILE: src/vr_hyperloglog.c
  type hllhdr (line 151) | struct hllhdr {
  function MurmurHash64A (line 362) | uint64_t MurmurHash64A (const void * key, int len, unsigned int seed) {
  function hllPatLen (line 413) | int hllPatLen(unsigned char *ele, size_t elesize, long *regp) {
  function hllDenseAdd (line 454) | int hllDenseAdd(uint8_t *registers, unsigned char *ele, size_t elesize) {
  function hllDenseSum (line 473) | double hllDenseSum(uint8_t *registers, double *PE, int *ezp) {
  function hllSparseToDense (line 537) | int hllSparseToDense(robj *o) {
  function hllSparseAdd (line 607) | int hllSparseAdd(robj *o, unsigned char *ele, size_t elesize) {
  function hllSparseSum (line 857) | double hllSparseSum(uint8_t *sparse, int sparselen, double *PE, int *ezp...
  function hllRawSum (line 897) | double hllRawSum(uint8_t *registers, double *PE, int *ezp) {
  function hllCount (line 936) | static uint64_t hllCount(struct hllhdr *hdr, int *invalid) {
  function hllAdd (line 996) | int hllAdd(robj *o, unsigned char *ele, size_t elesize) {
  function hllMerge (line 1013) | int hllMerge(uint8_t *max, robj *hll) {
  function robj (line 1058) | robj *createHLLObject(void) {
  function isHLLObjectOrReply (line 1093) | int isHLLObjectOrReply(client *c, robj *o) {
  function pfaddCommand (line 1124) | void pfaddCommand(client *c) {
  function pfcountCommand (line 1176) | void pfcountCommand(client *c) {
  function pfmergeCommand (line 1289) | void pfmergeCommand(client *c) {
  function pfselftestCommand (line 1355) | void pfselftestCommand(client *c) {
  function pfdebugCommand (line 1459) | void pfdebugCommand(client *c) {

FILE: src/vr_hyperloglog.h
  type client (line 15) | struct client
  type client (line 16) | struct client
  type client (line 17) | struct client
  type client (line 18) | struct client
  type client (line 19) | struct client
  type client (line 20) | struct client

FILE: src/vr_intset.c
  function _intsetValueEncoding (line 14) | static uint8_t _intsetValueEncoding(int64_t v) {
  function _intsetGetEncoded (line 24) | static int64_t _intsetGetEncoded(intset *is, int pos, uint8_t enc) {
  function _intsetGet (line 45) | static int64_t _intsetGet(intset *is, int pos) {
  function _intsetSet (line 50) | static void _intsetSet(intset *is, int pos, int64_t value) {
  function intset (line 66) | intset *intsetNew(void) {
  function intset (line 74) | static intset *intsetResize(intset *is, uint32_t len) {
  function intsetSearch (line 84) | static uint8_t intsetSearch(intset *is, int64_t value, uint32_t *pos) {
  function intset (line 126) | static intset *intsetUpgradeAndAdd(intset *is, int64_t value) {
  function intsetMoveTail (line 151) | static void intsetMoveTail(intset *is, uint32_t from, uint32_t to) {
  function intset (line 173) | intset *intsetAdd(intset *is, int64_t value, uint8_t *success) {
  function intset (line 203) | intset *intsetRemove(intset *is, int64_t value, int *success) {
  function intsetFind (line 223) | uint8_t intsetFind(intset *is, int64_t value) {
  function intsetRandom (line 229) | int64_t intsetRandom(intset *is) {
  function intsetGet (line 235) | uint8_t intsetGet(intset *is, uint32_t pos, int64_t *value) {
  function intsetLen (line 244) | uint32_t intsetLen(intset *is) {
  function intsetBlobLen (line 249) | size_t intsetBlobLen(intset *is) {

FILE: src/vr_intset.h
  type intset (line 6) | typedef struct intset {

FILE: src/vr_listen.c
  function vr_listen (line 6) | vr_listen *
  function vr_listen_destroy (line 102) | void
  function rstatus_t (line 122) | static rstatus_t
  function rstatus_t (line 153) | rstatus_t
  function vr_listen_accept (line 205) | int

FILE: src/vr_listen.h
  type vr_listen (line 4) | typedef struct vr_listen {
  type vr_listen (line 14) | struct vr_listen

FILE: src/vr_lzfP.h
  type u8 (line 120) | typedef unsigned char u8;
  type LZF_HSLOT (line 124) | typedef unsigned int LZF_HSLOT;
  type u8 (line 127) | typedef const u8 *LZF_HSLOT;
  type LZF_HSLOT (line 130) | typedef LZF_HSLOT LZF_STATE[1 << (HLOG)];
  type u16 (line 135) | typedef unsigned short u16;
  type u16 (line 137) | typedef unsigned int u16;

FILE: src/vr_lzf_c.c
  function lzf_compress (line 62) | unsigned int

FILE: src/vr_lzf_d.c
  function lzf_decompress (line 19) | unsigned int

FILE: src/vr_master.c
  function master_init (line 8) | int
  function master_deinit (line 63) | void
  function client_accept (line 78) | static void
  function cbsul_push (line 88) | static void
  type connswapunit (line 96) | struct connswapunit
  type connswapunit (line 99) | struct connswapunit
  function dispatch_conn_exist (line 108) | void
  function thread_event_process (line 138) | static void
  function setup_master (line 183) | static int
  function master_run (line 223) | int

FILE: src/vr_master.h
  type vr_master (line 4) | typedef struct vr_master {
  type client (line 19) | struct client

FILE: src/vr_multi.c
  type watchedKey (line 15) | typedef struct watchedKey {
  function unwatchAllKeys (line 22) | void unwatchAllKeys(client *c) {
  function initClientMultiState (line 49) | void initClientMultiState(client *c) {
  function freeClientMultiState (line 55) | void freeClientMultiState(client *c) {
  function queueMultiCommand (line 70) | void queueMultiCommand(client *c) {
  function flagTransaction (line 88) | void flagTransaction(client *c) {
  function execCommand (line 93) | void execCommand(client *c) {
  function discardCommand (line 97) | void discardCommand(client *c) {
  function discardTransaction (line 106) | void discardTransaction(client *c) {
  function multiCommand (line 113) | void multiCommand(client *c) {
  function watchForKey (line 123) | void watchForKey(client *c, robj *key) {
  function watchCommand (line 152) | void watchCommand(client *c) {
  function touchWatchedKey (line 166) | void touchWatchedKey(redisDb *db, robj *key) {
  function touchWatchedKeysOnFlush (line 189) | void touchWatchedKeysOnFlush(int dbid) {

FILE: src/vr_multi.h
  type multiCmd (line 5) | typedef struct multiCmd {
  type multiState (line 11) | typedef struct multiState {
  type client (line 18) | struct client
  type client (line 19) | struct client
  type client (line 20) | struct client
  type client (line 21) | struct client
  type client (line 23) | struct client
  type client (line 24) | struct client
  type client (line 25) | struct client
  type client (line 26) | struct client
  type client (line 27) | struct client
  type client (line 28) | struct client
  type client (line 29) | struct client

FILE: src/vr_notify.c
  function keyspaceEventsStringToFlags (line 11) | int keyspaceEventsStringToFlags(char *classes) {
  function sds (line 38) | sds keyspaceEventsFlagsToString(int flags) {
  function notifyKeyspaceEvent (line 66) | void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) {

FILE: src/vr_object.c
  function robj (line 10) | robj *createObject(int type, void *ptr) {
  function robj (line 23) | robj *createRawStringObject(const char *ptr, size_t len) {
  function robj (line 30) | robj *createEmbeddedStringObject(const char *ptr, size_t len) {
  function robj (line 60) | robj *createStringObject(const char *ptr, size_t len) {
  function robj (line 67) | robj *createStringObjectFromLongLong(long long value) {
  function robj (line 89) | robj *createStringObjectFromLongDouble(long double value, int humanfrien...
  function robj (line 133) | robj *dupStringObject(robj *o) {
  function robj (line 154) | robj *dupStringObjectUnconstant(robj *o) {
  function robj (line 159) | robj *createQuicklistObject(void) {
  function robj (line 166) | robj *createZiplistObject(void) {
  function robj (line 173) | robj *createSetObject(void) {
  function robj (line 180) | robj *createIntsetObject(void) {
  function robj (line 187) | robj *createHashObject(void) {
  function robj (line 198) | robj *createZsetObject(void) {
  function robj (line 209) | robj *createZsetZiplistObject(void) {
  function freeStringObject (line 216) | void freeStringObject(robj *o) {
  function freeListObject (line 222) | void freeListObject(robj *o) {
  function freeSetObject (line 232) | void freeSetObject(robj *o) {
  function freeZsetObject (line 245) | void freeZsetObject(robj *o) {
  function freeHashObject (line 262) | void freeHashObject(robj *o) {
  function incrRefCount (line 276) | void incrRefCount(robj *o) {
  function decrRefCount (line 280) | void decrRefCount(robj *o) {
  function decrRefCountVoid (line 300) | void decrRefCountVoid(void *o) {
  function freeObject (line 304) | void freeObject(robj *o) {
  function freeObjectVoid (line 318) | void freeObjectVoid(void *o) {
  function robj (line 334) | robj *resetRefCount(robj *obj) {
  function checkType (line 339) | int checkType(client *c, robj *o, int type) {
  function isObjectRepresentableAsLongLong (line 347) | int isObjectRepresentableAsLongLong(robj *o, long long *llval) {
  function robj (line 358) | robj *tryObjectEncoding(robj *o) {
  function robj (line 437) | robj *getDecodedObject(robj *o) {
  function compareStringObjectsWithFlags (line 465) | int compareStringObjectsWithFlags(robj *a, robj *b, int flags) {
  function compareStringObjects (line 498) | int compareStringObjects(robj *a, robj *b) {
  function collateStringObjects (line 503) | int collateStringObjects(robj *a, robj *b) {
  function equalStringObjects (line 511) | int equalStringObjects(robj *a, robj *b) {
  function stringObjectLen (line 522) | size_t stringObjectLen(robj *o) {
  function getDoubleFromObject (line 531) | int getDoubleFromObject(robj *o, double *target) {
  function getDoubleFromObjectOrReply (line 559) | int getDoubleFromObjectOrReply(client *c, robj *o, double *target, const...
  function getLongDoubleFromObject (line 573) | int getLongDoubleFromObject(robj *o, long double *target) {
  function getLongDoubleFromObjectOrReply (line 597) | int getLongDoubleFromObjectOrReply(client *c, robj *o, long double *targ...
  function getLongLongFromObject (line 611) | int getLongLongFromObject(robj *o, long long *target) {
  function getLongLongFromObjectOrReply (line 635) | int getLongLongFromObjectOrReply(client *c, robj *o, long long *target, ...
  function getLongFromObjectOrReply (line 649) | int getLongFromObjectOrReply(client *c, robj *o, long *target, const cha...
  function estimateObjectIdleTime (line 681) | unsigned long long estimateObjectIdleTime(robj *o) {
  function getStringObjectSdsUsedMemory (line 693) | size_t getStringObjectSdsUsedMemory(robj *o) {
  function robj (line 704) | robj *objectCommandLookup(client *c, robj *key) {
  function robj (line 711) | robj *objectCommandLookupOrReply(client *c, robj *key, robj *reply) {
  function objectCommand (line 720) | void objectCommand(client *c) {

FILE: src/vr_object.h
  type robj (line 37) | typedef struct vr_object {
  type client (line 76) | struct client
  type client (line 77) | struct client
  type client (line 78) | struct client
  type client (line 79) | struct client
  type client (line 82) | struct client
  type client (line 91) | struct client
  type client (line 92) | struct client
  type client (line 93) | struct client

FILE: src/vr_pubsub.c
  function pubsubUnsubscribeChannel (line 5) | int pubsubUnsubscribeChannel(client *c, robj *channel, int notify) {
  function pubsubUnsubscribeAllChannels (line 45) | int pubsubUnsubscribeAllChannels(client *c, int notify) {
  function pubsubUnsubscribePattern (line 69) | int pubsubUnsubscribePattern(client *c, robj *pattern, int notify) {
  function pubsubUnsubscribeAllPatterns (line 97) | int pubsubUnsubscribeAllPatterns(client *c, int notify) {
  function pubsubSubscribeChannel (line 126) | int pubsubSubscribeChannel(client *c, robj *channel) {
  function subscribeCommand (line 154) | void subscribeCommand(client *c) {
  function clientSubscriptionsCount (line 163) | int clientSubscriptionsCount(client *c) {
  function unsubscribeCommand (line 168) | void unsubscribeCommand(client *c) {
  function pubsubSubscribePattern (line 181) | int pubsubSubscribePattern(client *c, robj *pattern) {
  function psubscribeCommand (line 202) | void psubscribeCommand(client *c) {
  function punsubscribeCommand (line 210) | void punsubscribeCommand(client *c) {
  function pubsubPublishMessage (line 223) | int pubsubPublishMessage(robj *channel, robj *message) {

FILE: src/vr_pubsub.h
  type pubsubPattern (line 4) | typedef struct pubsubPattern {

FILE: src/vr_quicklist.c
  function quicklist (line 61) | quicklist *quicklistCreate(void) {
  function quicklistSetCompressDepth (line 74) | void quicklistSetCompressDepth(quicklist *quicklist, int compress) {
  function quicklistSetFill (line 84) | void quicklistSetFill(quicklist *quicklist, int fill) {
  function quicklistSetOptions (line 93) | void quicklistSetOptions(quicklist *quicklist, int fill, int depth) {
  function quicklist (line 99) | quicklist *quicklistNew(int fill, int compress) {
  function REDIS_STATIC (line 105) | REDIS_STATIC quicklistNode *quicklistCreateNode(void) {
  function quicklistCount (line 119) | unsigned int quicklistCount(quicklist *ql) { return ql->count; }
  function quicklistRelease (line 122) | void quicklistRelease(quicklist *quicklist) {
  function REDIS_STATIC (line 145) | REDIS_STATIC int __quicklistCompressNode(quicklistNode *node) {
  function REDIS_STATIC (line 182) | REDIS_STATIC int __quicklistDecompressNode(quicklistNode *node) {
  function quicklistGetLzf (line 220) | size_t quicklistGetLzf(const quicklistNode *node, void **data) {
  function REDIS_STATIC (line 232) | REDIS_STATIC void __quicklistCompress(const quicklist *quicklist,
  function REDIS_STATIC (line 319) | REDIS_STATIC void __quicklistInsertNode(quicklist *quicklist,
  function REDIS_STATIC (line 355) | REDIS_STATIC void _quicklistInsertNodeBefore(quicklist *quicklist,
  function REDIS_STATIC (line 361) | REDIS_STATIC void _quicklistInsertNodeAfter(quicklist *quicklist,
  function REDIS_STATIC (line 367) | REDIS_STATIC int
  function REDIS_STATIC (line 387) | REDIS_STATIC int _quicklistNodeAllowInsert(const quicklistNode *node,
  function REDIS_STATIC (line 419) | REDIS_STATIC int _quicklistNodeAllowMerge(const quicklistNode *a,
  function quicklistPushHead (line 447) | int quicklistPushHead(quicklist *quicklist, void *value, size_t sz) {
  function quicklistPushTail (line 470) | int quicklistPushTail(quicklist *quicklist, void *value, size_t sz) {
  function quicklistAppendZiplist (line 492) | void quicklistAppendZiplist(quicklist *quicklist, unsigned char *zl) {
  function quicklist (line 509) | quicklist *quicklistAppendValuesFromZiplist(quicklist *quicklist,
  function quicklist (line 533) | quicklist *quicklistCreateFromZiplist(int fill, int compress,
  function REDIS_STATIC (line 546) | REDIS_STATIC void __quicklistDelNode(quicklist *quicklist,
  function REDIS_STATIC (line 580) | REDIS_STATIC int quicklistDelIndex(quicklist *quicklist, quicklistNode *...
  function quicklistDelEntry (line 601) | void quicklistDelEntry(quicklistIter *iter, quicklistEntry *entry) {
  function quicklistReplaceAtIndex (line 634) | int quicklistReplaceAtIndex(quicklist *quicklist, long index, void *data,
  function REDIS_STATIC (line 661) | REDIS_STATIC quicklistNode *_quicklistZiplistMerge(quicklist *quicklist,
  function REDIS_STATIC (line 699) | REDIS_STATIC void _quicklistMergeNodes(quicklist *quicklist,
  function REDIS_STATIC (line 763) | REDIS_STATIC quicklistNode *_quicklistSplitNode(quicklistNode *node, int...
  function REDIS_STATIC (line 798) | REDIS_STATIC void _quicklistInsert(quicklist *quicklist, quicklistEntry ...
  function quicklistInsertBefore (line 908) | void quicklistInsertBefore(quicklist *quicklist, quicklistEntry *entry,
  function quicklistInsertAfter (line 913) | void quicklistInsertAfter(quicklist *quicklist, quicklistEntry *entry,
  function quicklistDelRange (line 924) | int quicklistDelRange(quicklist *quicklist, const long start,
  function quicklistCompare (line 1008) | int quicklistCompare(unsigned char *p1, unsigned char *p2, int p2_len) {
  function quicklistIter (line 1014) | quicklistIter *quicklistGetIterator(const quicklist *quicklist, int dire...
  function quicklistIter (line 1037) | quicklistIter *quicklistGetIteratorAtIdx(const quicklist *quicklist,
  function quicklistReleaseIterator (line 1055) | void quicklistReleaseIterator(quicklistIter *iter) {
  function quicklistNext (line 1083) | int quicklistNext(quicklistIter *iter, quicklistEntry *entry) {
  function quicklist (line 1152) | quicklist *quicklistDup(quicklist *orig) {
  function quicklistIndex (line 1192) | int quicklistIndex(const quicklist *quicklist, const long long idx,
  function quicklistRotate (line 1249) | void quicklistRotate(quicklist *quicklist) {
  function quicklistPopCustom (line 1291) | int quicklistPopCustom(quicklist *quicklist, int where, unsigned char **...
  function REDIS_STATIC (line 1339) | REDIS_STATIC void *_quicklistSaver(unsigned char *data, unsigned int sz) {
  function quicklistPop (line 1352) | int quicklistPop(quicklist *quicklist, int where, unsigned char **data,
  function quicklistPush (line 1371) | void quicklistPush(quicklist *quicklist, void *value, const size_t sz,

FILE: src/vr_quicklist.h
  type quicklistNode (line 14) | typedef struct quicklistNode {
  type quicklistLZF (line 32) | typedef struct quicklistLZF {
  type quicklist (line 43) | typedef struct quicklist {
  type quicklistIter (line 52) | typedef struct quicklistIter {
  type quicklistEntry (line 60) | typedef struct quicklistEntry {

FILE: src/vr_rbtree.c
  function rbtree_node_init (line 3) | void
  function rbtree_init (line 14) | void
  type rbnode (line 23) | struct rbnode
  type rbnode (line 24) | struct rbnode
  type rbnode (line 24) | struct rbnode
  type rbnode (line 35) | struct rbnode
  type rbtree (line 36) | struct rbtree
  type rbnode (line 38) | struct rbnode
  type rbnode (line 39) | struct rbnode
  function rbtree_left_rotate (line 50) | static void
  function rbtree_right_rotate (line 77) | static void
  function rbtree_insert (line 104) | void
  function rbtree_delete (line 186) | void

FILE: src/vr_rbtree.h
  type rbnode (line 10) | struct rbnode {
  type rbtree (line 19) | struct rbtree {
  type rbnode (line 24) | struct rbnode
  type rbtree (line 25) | struct rbtree
  type rbnode (line 25) | struct rbnode
  type rbnode (line 26) | struct rbnode
  type rbtree (line 26) | struct rbtree
  type rbtree (line 27) | struct rbtree
  type rbnode (line 27) | struct rbnode
  type rbtree (line 28) | struct rbtree
  type rbnode (line 28) | struct rbnode

FILE: src/vr_rdb.c
  function rdbSave (line 4) | int rdbSave(char *filename) {
  function rdbRemoveTempFile (line 8) | void rdbRemoveTempFile(pid_t childpid) {

FILE: src/vr_rdb.h
  type saveparam (line 31) | struct saveparam {

FILE: src/vr_replication.c
  type vr_replication (line 3) | struct vr_replication
  function vr_replication_init (line 5) | int vr_replication_init(void)
  function vr_replication_deinit (line 34) | void vr_replication_deinit(void)
  function unblockClientWaitingReplicas (line 67) | void unblockClientWaitingReplicas(client *c) {
  function refreshGoodSlavesCount (line 78) | void refreshGoodSlavesCount(void) {
  function replicationHandleMasterDisconnection (line 99) | void replicationHandleMasterDisconnection(void) {
  function replicationCacheMaster (line 129) | void replicationCacheMaster(client *c) {
  function replconfCommand (line 178) | void replconfCommand(client *c) {
  function putSlaveOnline (line 246) | void putSlaveOnline(client *slave) {
  function replicationSendAck (line 264) | void replicationSendAck(void) {
  function replicationFeedMonitors (line 277) | void replicationFeedMonitors(client *c, dlist *monitors, int dictid, rob...
  function feedReplicationBacklog (line 320) | void feedReplicationBacklog(void *ptr, size_t len) {
  function feedReplicationBacklogWithObject (line 347) | void feedReplicationBacklogWithObject(robj *o) {
  function replicationFeedSlaves (line 362) | void replicationFeedSlaves(dlist *slaves, int dictid, robj **argv, int a...

FILE: src/vr_replication.h
  type vr_replication (line 46) | struct vr_replication {
  type vr_replication (line 97) | struct vr_replication

FILE: src/vr_scripting.c
  function scriptCommand (line 3) | void scriptCommand(client *c) {

FILE: src/vr_server.c
  type vr_server (line 6) | struct vr_server
  type sharedObjectsStruct (line 9) | struct sharedObjectsStruct
  function dictStrHash (line 11) | unsigned int
  function dictStrCaseHash (line 16) | unsigned int
  function dictSdsHash (line 21) | unsigned int
  function dictSdsCaseHash (line 26) | unsigned int
  function dictStrKeyCompare (line 31) | int
  function dictStrKeyCaseCompare (line 46) | int
  function dictSdsKeyCompare (line 55) | int
  function dictSdsKeyCaseCompare (line 70) | int
  function dictSdsDestructor (line 87) | void
  function dictObjectDestructor (line 95) | void
  function dictEncObjKeyCompare (line 104) | int
  function dictEncObjHash (line 124) | unsigned int
  function dictObjHash (line 149) | unsigned int
  function dictObjKeyCompare (line 155) | int
  function dictListDestructor (line 163) | void
  function createSharedObjects (line 202) | static void createSharedObjects(void) {
  function init_server (line 303) | int
  function getLRUClock (line 415) | unsigned int getLRUClock(void) {
  function evictionPoolPopulate (line 429) | void evictionPoolPopulate(dict *sampledict, dict *keydict,
  function freeMemoryIfNeeded (line 495) | int freeMemoryIfNeeded(vr_eventloop *vel) {
  function pingCommand (line 629) | void pingCommand(client *c) {
  function time_independent_strcmp (line 661) | int time_independent_strcmp(char *a, char *b) {
  function authCommand (line 694) | void authCommand(client *c) {
  function adminCommand (line 712) | void adminCommand(client *c) {
  function htNeedsResize (line 729) | int htNeedsResize(dict *dict) {
  type keys_statistics (line 738) | struct keys_statistics {
  function sds (line 748) | sds genVireInfoString(vr_eventloop *vel, char *section) {
  function infoCommand (line 1077) | void infoCommand(client *c) {
  function echoCommand (line 1087) | void echoCommand(client *c) {
  function timeCommand (line 1091) | void timeCommand(client *c) {
  function adjustOpenFilesLimit (line 1110) | int adjustOpenFilesLimit(int maxclients) {

FILE: src/vr_server.h
  type readyList (line 75) | typedef struct readyList {
  type vr_server (line 80) | struct vr_server {
  type zskiplistNode (line 237) | typedef struct zskiplistNode {
  type zskiplist (line 247) | typedef struct zskiplist {
  type zset (line 253) | typedef struct zset {
  type listTypeIterator (line 259) | typedef struct {
  type listTypeEntry (line 267) | typedef struct {
  type setTypeIterator (line 273) | typedef struct {
  type hashTypeIterator (line 284) | typedef struct {
  type sharedObjectsStruct (line 294) | struct sharedObjectsStruct {
  type vr_server (line 312) | struct vr_server
  type sharedObjectsStruct (line 313) | struct sharedObjectsStruct
  type instance (line 338) | struct instance
  type client (line 343) | struct client
  type client (line 345) | struct client
  type client (line 346) | struct client

FILE: src/vr_signal.c
  type signal (line 7) | struct signal
  function rstatus_t (line 19) | rstatus_t
  function signal_deinit (line 44) | void
  function signal_handler (line 49) | void

FILE: src/vr_signal.h
  type signal (line 4) | struct signal {

FILE: src/vr_slowlog.c
  function slowlogEntry (line 10) | slowlogEntry *slowlogCreateEntry(robj **argv, int argc, long long durati...
  function slowlogFreeEntry (line 51) | void slowlogFreeEntry(void *septr) {
  function slowlogInit (line 63) | void slowlogInit(void) {
  function slowlogPushEntryIfNeeded (line 73) | void slowlogPushEntryIfNeeded(vr_eventloop *vel, robj **argv, int argc, ...
  function slowlogReset (line 96) | void slowlogReset(void) {
  function slowlogCommand (line 105) | void slowlogCommand(client *c) {

FILE: src/vr_slowlog.h
  type slowlogEntry (line 8) | typedef struct slowlogEntry {

FILE: src/vr_stats.c
  function vr_stats_init (line 3) | int
  function vr_stats_deinit (line 39) | void
  function trackInstantaneousMetric (line 66) | void trackInstantaneousMetric(vr_stats *stats, int metric, long long cur...
  function getInstantaneousMetric (line 82) | long long getInstantaneousMetric(vr_stats *stats, int metric) {

FILE: src/vr_stats.h
  type vr_stats (line 15) | typedef struct vr_stats {

FILE: src/vr_t_hash.c
  function hashTypeTryConversion (line 12) | void hashTypeTryConversion(robj *o, robj **argv, int start, int end) {
  function hashTypeTryObjectEncoding (line 28) | void hashTypeTryObjectEncoding(robj *subject, robj **o1, robj **o2) {
  function hashTypeGetFromZiplist (line 37) | int hashTypeGetFromZiplist(robj *o, robj *field,
  function hashTypeGetFromHashTable (line 74) | int hashTypeGetFromHashTable(robj *o, robj *field, robj **value) {
  function robj (line 91) | robj *hashTypeGetObject(robj *o, robj *field) {
  function hashTypeGetValueLength (line 121) | size_t hashTypeGetValueLength(robj *o, robj *field) {
  function hashTypeExists (line 143) | int hashTypeExists(robj *o, robj *field) {
  function hashTypeSet (line 165) | int hashTypeSet(robj *o, robj *field, robj *value) {
  function hashTypeDelete (line 222) | int hashTypeDelete(robj *o, robj *field) {
  function hashTypeLength (line 260) | unsigned long hashTypeLength(robj *o) {
  function hashTypeIterator (line 274) | hashTypeIterator *hashTypeInitIterator(robj *subject) {
  function hashTypeReleaseIterator (line 291) | void hashTypeReleaseIterator(hashTypeIterator *hi) {
  function hashTypeNext (line 301) | int hashTypeNext(hashTypeIterator *hi) {
  function hashTypeCurrentFromZiplist (line 338) | void hashTypeCurrentFromZiplist(hashTypeIterator *hi, int what,
  function hashTypeCurrentFromHashTable (line 358) | void hashTypeCurrentFromHashTable(hashTypeIterator *hi, int what, robj *...
  function robj (line 371) | robj *hashTypeCurrentObject(hashTypeIterator *hi, int what) {
  function robj (line 393) | robj *hashTypeLookupWriteOrCreate(client *c, robj *key, int *expired) {
  function hashTypeConvertZiplist (line 407) | void hashTypeConvertZiplist(robj *o, int enc) {
  function hashTypeConvert (line 447) | void hashTypeConvert(robj *o, int enc) {
  function hsetCommand (line 461) | void hsetCommand(client *c) {
  function hsetnxCommand (line 484) | void hsetnxCommand(client *c) {
  function hmsetCommand (line 512) | void hmsetCommand(client *c) {
  function hincrbyCommand (line 543) | void hincrbyCommand(client *c) {
  function hincrbyfloatCommand (line 585) | void hincrbyfloatCommand(client *c) {
  function addHashFieldToReply (line 632) | static void addHashFieldToReply(client *c, robj *o, robj *field) {
  function hgetCommand (line 671) | void hgetCommand(client *c) {
  function hmgetCommand (line 691) | void hmgetCommand(client *c) {
  function hdelCommand (line 722) | void hdelCommand(client *c) {
  function hlenCommand (line 761) | void hlenCommand(client *c) {
  function hstrlenCommand (line 781) | void hstrlenCommand(client *c) {
  function addHashIteratorCursorToReply (line 802) | static void addHashIteratorCursorToReply(client *c, hashTypeIterator *hi...
  function genericHgetallCommand (line 826) | void genericHgetallCommand(client *c, int flags) {
  function hkeysCommand (line 868) | void hkeysCommand(client *c) {
  function hvalsCommand (line 872) | void hvalsCommand(client *c) {
  function hgetallCommand (line 876) | void hgetallCommand(client *c) {
  function hexistsCommand (line 880) | void hexistsCommand(client *c) {
  function hscanCommand (line 900) | void hscanCommand(client *c) {

FILE: src/vr_t_list.c
  function listTypePush (line 12) | void listTypePush(robj *subject, robj *value, int where) {
  function robj (line 29) | robj *listTypePop(robj *subject, int where) {
  function listTypeLength (line 46) | unsigned long listTypeLength(robj *subject) {
  function listTypeIterator (line 55) | listTypeIterator *listTypeInitIterator(robj *subject, long index,
  function listTypeReleaseIterator (line 76) | void listTypeReleaseIterator(listTypeIterator *li) {
  function listTypeNext (line 84) | int listTypeNext(listTypeIterator *li, listTypeEntry *entry) {
  function robj (line 98) | robj *listTypeGet(listTypeEntry *entry) {
  function listTypeInsert (line 113) | void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
  function listTypeEqual (line 132) | int listTypeEqual(listTypeEntry *entry, robj *o) {
  function listTypeDelete (line 142) | void listTypeDelete(listTypeIterator *iter, listTypeEntry *entry) {
  function listTypeConvert (line 151) | void listTypeConvert(robj *subject, int enc) {
  function pushGenericCommand (line 169) | void pushGenericCommand(client *c, int where) {
  function lpushCommand (line 208) | void lpushCommand(client *c) {
  function rpushCommand (line 212) | void rpushCommand(client *c) {
  function pushxGenericCommand (line 216) | void pushxGenericCommand(client *c, robj *refval, robj *val, int where) {
  function lpushxCommand (line 259) | void lpushxCommand(client *c) {
  function rpushxCommand (line 264) | void rpushxCommand(client *c) {
  function linsertCommand (line 269) | void linsertCommand(client *c) {
  function llenCommand (line 280) | void llenCommand(client *c) {
  function lindexCommand (line 301) | void lindexCommand(client *c) {
  function lsetCommand (line 341) | void lsetCommand(client *c) {
  function popGenericCommand (line 378) | void popGenericCommand(client *c, int where) {
  function lpopCommand (line 412) | void lpopCommand(client *c) {
  function rpopCommand (line 416) | void rpopCommand(client *c) {
  function lrangeCommand (line 420) | void lrangeCommand(client *c) {
  function ltrimCommand (line 481) | void ltrimCommand(client *c) {
  function lremCommand (line 536) | void lremCommand(client *c) {
  function rpoplpushHandlePush (line 604) | void rpoplpushHandlePush(client *c, robj *dstkey, robj *dstobj, robj *va...
  function rpoplpushCommand (line 619) | void rpoplpushCommand(client *c) {
  function blockForKeys (line 679) | void blockForKeys(client *c, robj **keys, int numkeys, mstime_t timeout,...
  function unblockClientWaitingData (line 714) | void unblockClientWaitingData(client *c) {
  function signalListAsReady (line 750) | void signalListAsReady(redisDb *db, robj *key) {
  function serveClientBlockedOnList (line 794) | int serveClientBlockedOnList(client *receiver, robj *key, robj *dstkey, ...
  function handleClientsBlockedOnLists (line 854) | void handleClientsBlockedOnLists(void) {
  function blockingPopGenericCommand (line 936) | void blockingPopGenericCommand(client *c, int where) {
  function blpopCommand (line 992) | void blpopCommand(client *c) {
  function brpopCommand (line 996) | void brpopCommand(client *c) {
  function brpoplpushCommand (line 1000) | void brpoplpushCommand(client *c) {

FILE: src/vr_t_set.c
  function robj (line 13) | robj *setTypeCreate(robj *value) {
  function setTypeAdd (line 24) | int setTypeAdd(robj *subject, robj *value) {
  function setTypeRemove (line 61) | int setTypeRemove(robj *setobj, robj *value) {
  function setTypeIsMember (line 80) | int setTypeIsMember(robj *subject, robj *value) {
  function setTypeIterator (line 94) | setTypeIterator *setTypeInitIterator(robj *subject) {
  function setTypeReleaseIterator (line 108) | void setTypeReleaseIterator(setTypeIterator *si) {
  function setTypeNext (line 129) | int setTypeNext(setTypeIterator *si, robj **objele, int64_t *llele) {
  function robj (line 153) | robj *setTypeNextObject(setTypeIterator *si) {
  function setTypeRandomElement (line 188) | int setTypeRandomElement(robj *setobj, robj **objele, int64_t *llele) {
  function setTypeSize (line 202) | unsigned long setTypeSize(robj *subject) {
  function setTypeConvert (line 215) | void setTypeConvert(robj *setobj, int enc) {
  function saddCommand (line 245) | void saddCommand(client *c) {
  function sremCommand (line 279) | void sremCommand(client *c) {
  function smoveCommand (line 316) | void smoveCommand(client *c) {
  function sismemberCommand (line 369) | void sismemberCommand(client *c) {
  function scardCommand (line 394) | void scardCommand(client *c) {
  function smembersGenericCommand (line 414) | void smembersGenericCommand(client *c, robj *set)
  function spopWithCountCommand (line 441) | void spopWithCountCommand(client *c) {
  function spopCommand (line 600) | void spopCommand(client *c) {
  function srandmemberWithCountCommand (line 668) | void srandmemberWithCountCommand(client *c) {
  function srandmemberCommand (line 802) | void srandmemberCommand(client *c) {
  function smembersCommand (line 826) | void smembersCommand(client *c) {
  function qsortCompareSetsByCardinality (line 847) | int qsortCompareSetsByCardinality(const void *s1, const void *s2) {
  function qsortCompareSetsByRevCardinality (line 853) | int qsortCompareSetsByRevCardinality(const void *s1, const void *s2) {
  function sinterGenericCommand (line 859) | void sinterGenericCommand(client *c, robj **setkeys,
  function sinterCommand (line 1056) | void sinterCommand(client *c) {
  function sinterstoreCommand (line 1060) | void sinterstoreCommand(client *c) {
  function sunionDiffGenericCommand (line 1068) | void sunionDiffGenericCommand(client *c, robj **setkeys, int setnum,
  function sunionCommand (line 1309) | void sunionCommand(client *c) {
  function sunionstoreCommand (line 1313) | void sunionstoreCommand(client *c) {
  function sdiffCommand (line 1317) | void sdiffCommand(client *c) {
  function sdiffstoreCommand (line 1321) | void sdiffstoreCommand(client *c) {
  function sscanCommand (line 1325) | void sscanCommand(client *c) {

FILE: src/vr_t_string.c
  function checkStringLength (line 7) | static int checkStringLength(client *c, long long size) {
  function setGenericCommand (line 37) | void setGenericCommand(client *c, int flags, robj *key, robj *val, robj ...
  function setCommand (line 80) | void setCommand(client *c) {
  function setnxCommand (line 126) | void setnxCommand(client *c) {
  function setexCommand (line 131) | void setexCommand(client *c) {
  function psetexCommand (line 136) | void psetexCommand(client *c) {
  function getGenericCommand (line 141) | int getGenericCommand(client *c) {
  function getCommand (line 157) | void getCommand(client *c) {
  function getsetCommand (line 178) | void getsetCommand(client *c) {
  function setrangeCommand (line 216) | void setrangeCommand(client *c) {
  function getrangeCommand (line 294) | void getrangeCommand(client *c) {
  function mgetCommand (line 343) | void mgetCommand(client *c) {
  function msetGenericCommand (line 367) | void msetGenericCommand(client *c, int nx) {
  function msetCommand (line 397) | void msetCommand(client *c) {
  function msetnxCommand (line 421) | void msetnxCommand(client *c) {
  function incrDecrCommand (line 425) | void incrDecrCommand(client *c, long long incr) {
  function incrCommand (line 470) | void incrCommand(client *c) {
  function decrCommand (line 474) | void decrCommand(client *c) {
  function incrbyCommand (line 478) | void incrbyCommand(client *c) {
  function decrbyCommand (line 485) | void decrbyCommand(client *c) {
  function incrbyfloatCommand (line 492) | void incrbyfloatCommand(client *c) {
  function appendCommand (line 533) | void appendCommand(client *c) {
  function strlenCommand (line 572) | void strlenCommand(client *c) {

FILE: src/vr_t_zset.c
  function zskiplistNode (line 6) | zskiplistNode *zslCreateNode(int level, double score, robj *obj) {
  function zskiplist (line 13) | zskiplist *zslCreate(void) {
  function zslFreeNode (line 30) | void zslFreeNode(zskiplistNode *node) {
  function zslFree (line 35) | void zslFree(zskiplist *zsl) {
  function zslRandomLevel (line 51) | int zslRandomLevel(void) {
  function zskiplistNode (line 58) | zskiplistNode *zslInsert(zskiplist *zsl, double score, robj *obj) {
  function zslDeleteNode (line 115) | void zslDeleteNode(zskiplist *zsl, zskiplistNode *x, zskiplistNode **upd...
  function zslDelete (line 136) | int zslDelete(zskiplist *zsl, double score, robj *obj) {
  function zslValueGteMin (line 160) | static int zslValueGteMin(double value, zrangespec *spec) {
  function zslValueLteMax (line 164) | int zslValueLteMax(double value, zrangespec *spec) {
  function zslIsInRange (line 169) | int zslIsInRange(zskiplist *zsl, zrangespec *range) {
  function zskiplistNode (line 187) | zskiplistNode *zslFirstInRange(zskiplist *zsl, zrangespec *range) {
  function zskiplistNode (line 213) | zskiplistNode *zslLastInRange(zskiplist *zsl, zrangespec *range) {
  function zslDeleteRangeByScore (line 240) | unsigned long zslDeleteRangeByScore(zskiplist *zsl, zrangespec *range, d...
  function zslDeleteRangeByLex (line 271) | unsigned long zslDeleteRangeByLex(zskiplist *zsl, zlexrangespec *range, ...
  function zslDeleteRangeByRank (line 302) | unsigned long zslDeleteRangeByRank(zskiplist *zsl, unsigned int start, u...
  function zslGetRank (line 334) | unsigned long zslGetRank(zskiplist *zsl, double score, robj *o) {
  function zskiplistNode (line 358) | zskiplistNode* zslGetElementByRank(zskiplist *zsl, unsigned long rank) {
  function zslParseRange (line 378) | static int zslParseRange(robj *min, robj *max, zrangespec *spec) {
  function zslParseLexRangeItem (line 429) | int zslParseLexRangeItem(robj *item, robj **dest, int *ex) {
  function zslParseLexRange (line 461) | static int zslParseLexRange(robj *min, robj *max, zlexrangespec *spec) {
  function zslFreeLexRange (line 480) | void zslFreeLexRange(zlexrangespec *spec) {
  function compareStringObjectsForLexRange (line 488) | int compareStringObjectsForLexRange(robj *a, robj *b) {
  function zslLexValueGteMin (line 496) | static int zslLexValueGteMin(robj *value, zlexrangespec *spec) {
  function zslLexValueLteMax (line 502) | static int zslLexValueLteMax(robj *value, zlexrangespec *spec) {
  function zslIsInLexRange (line 509) | int zslIsInLexRange(zskiplist *zsl, zlexrangespec *range) {
  function zskiplistNode (line 528) | zskiplistNode *zslFirstInLexRange(zskiplist *zsl, zlexrangespec *range) {
  function zskiplistNode (line 554) | zskiplistNode *zslLastInLexRange(zskiplist *zsl, zlexrangespec *range) {
  function zzlGetScore (line 581) | double zzlGetScore(unsigned char *sptr) {
  function robj (line 608) | robj *ziplistGetObject(unsigned char *sptr) {
  function zzlCompareElements (line 627) | int zzlCompareElements(unsigned char *eptr, unsigned char *cstr, unsigne...
  function zzlLength (line 649) | unsigned int zzlLength(unsigned char *zl) {
  function zzlNext (line 655) | void zzlNext(unsigned char *zl, unsigned char **eptr, unsigned char **sp...
  function zzlPrev (line 674) | void zzlPrev(unsigned char *zl, unsigned char **eptr, unsigned char **sp...
  function zzlIsInRange (line 693) | int zzlIsInRange(unsigned char *zl, zrangespec *range) {
  function zzlLexValueGteMin (line 780) | static int zzlLexValueGteMin(unsigned char *p, zlexrangespec *spec) {
  function zzlLexValueLteMax (line 787) | static int zzlLexValueLteMax(unsigned char *p, zlexrangespec *spec) {
  function zzlIsInLexRange (line 796) | int zzlIsInLexRange(unsigned char *zl, zlexrangespec *range) {
  function zsetLength (line 1041) | unsigned int zsetLength(robj *zobj) {
  function zsetConvert (line 1053) | void zsetConvert(robj *zobj, int encoding) {
  function zsetConvertToZiplistIfNeeded (line 1130) | void zsetConvertToZiplistIfNeeded(robj *zobj, size_t maxelelen) {
  function zsetScore (line 1143) | int zsetScore(robj *zobj, robj *member, double *score) {
  function zaddGenericCommand (line 1170) | void zaddGenericCommand(client *c, int flags) {
  function zaddCommand (line 1376) | void zaddCommand(client *c) {
  function zincrbyCommand (line 1380) | void zincrbyCommand(client *c) {
  function zremCommand (line 1384) | void zremCommand(client *c) {
  function zremrangeGenericCommand (line 1457) | void zremrangeGenericCommand(client *c, int rangetype) {
  function zremrangebyrankCommand (line 1562) | void zremrangebyrankCommand(client *c) {
  function zremrangebyscoreCommand (line 1566) | void zremrangebyscoreCommand(client *c) {
  function zremrangebylexCommand (line 1570) | void zremrangebylexCommand(client *c) {
  type iterset (line 1584) | typedef union _iterset iterset;
  type iterzset (line 1585) | typedef union _iterzset iterzset;
  function zuiInitIterator (line 1587) | void zuiInitIterator(zsetopsrc *op) {
  function zuiClearIterator (line 1623) | void zuiClearIterator(zsetopsrc *op) {
  function zuiLength (line 1650) | int zuiLength(zsetopsrc *op) {
  function zuiNext (line 1680) | int zuiNext(zsetopsrc *op, zsetopval *val) {
  function zuiLongLongFromValue (line 1743) | int zuiLongLongFromValue(zsetopval *val) {
  function robj (line 1768) | robj *zuiObjectFromValue(zsetopval *val) {
  function zuiBufferFromValue (line 1780) | int zuiBufferFromValue(zsetopval *val) {
  function zuiFind (line 1802) | int zuiFind(zsetopsrc *op, zsetopval *val, double *score) {
  function zuiCompareByCardinality (line 1855) | int zuiCompareByCardinality(const void *s1, const void *s2) {
  function zunionInterAggregate (line 1864) | inline static void zunionInterAggregate(double *target, double val, int ...
  function zunionInterGenericCommand (line 1885) | void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
  function zunionstoreCommand (line 2122) | void zunionstoreCommand(client *c) {
  function zinterstoreCommand (line 2126) | void zinterstoreCommand(client *c) {
  function zrangeGenericCommand (line 2130) | void zrangeGenericCommand(client *c, int reverse) {
  function zrangeCommand (line 2246) | void zrangeCommand(client *c) {
  function zrevrangeCommand (line 2250) | void zrevrangeCommand(client *c) {
  function genericZrangebyscoreCommand (line 2255) | void genericZrangebyscoreCommand(client *c, int reverse) {
  function zrangebyscoreCommand (line 2456) | void zrangebyscoreCommand(client *c) {
  function zrevrangebyscoreCommand (line 2460) | void zrevrangebyscoreCommand(client *c) {
  function zcountCommand (line 2464) | void zcountCommand(client *c) {
  function zlexcountCommand (line 2554) | void zlexcountCommand(client *c) {
  function genericZrangebylexCommand (line 2634) | void genericZrangebylexCommand(client *c, int reverse) {
  function zrangebylexCommand (line 2810) | void zrangebylexCommand(client *c) {
  function zrevrangebylexCommand (line 2814) | void zrevrangebylexCommand(client *c) {
  function zcardCommand (line 2818) | void zcardCommand(client *c) {
  function zscoreCommand (line 2840) | void zscoreCommand(client *c) {
  function zrankGenericCommand (line 2867) | void zrankGenericCommand(client *c, int reverse) {
  function zrankCommand (line 2941) | void zrankCommand(client *c) {
  function zrevrankCommand (line 2945) | void zrevrankCommand(client *c) {
  function zscanCommand (line 2949) | void zscanCommand(client *c) {

FILE: src/vr_t_zset.h
  type zrangespec (line 5) | typedef struct {
  type zlexrangespec (line 11) | typedef struct {
  type zsetopsrc (line 16) | typedef struct {
  type zsetopval (line 51) | typedef struct {

FILE: src/vr_thread.c
  function vr_thread_init (line 3) | int
  function vr_thread_deinit (line 18) | void
  function vr_thread_start (line 39) | int vr_thread_start(vr_thread *thread)

FILE: src/vr_thread.h
  type vr_thread (line 6) | typedef struct vr_thread {

FILE: src/vr_util.c
  function vr_set_blocking (line 23) | int
  function vr_set_nonblocking (line 36) | int
  function vr_set_reuseaddr (line 49) | int
  function vr_set_tcpnodelay (line 69) | int
  function vr_set_linger (line 81) | int
  function vr_set_sndbuf (line 95) | int
  function vr_set_rcvbuf (line 105) | int
  function vr_get_soerror (line 115) | int
  function vr_get_sndbuf (line 132) | int
  function vr_get_rcvbuf (line 149) | int
  function vr_set_tcpkeepalive (line 166) | int
  function _vr_atoi (line 214) | int
  function digits10 (line 240) | uint32_t digits10(uint64_t v) {
  function sdigits10 (line 261) | uint32_t sdigits10(int64_t v) {
  function ll2string (line 283) | int
  function string2ll (line 341) | int
  function string2l (line 408) | int string2l(const char *s, size_t slen, long *lval) {
  function d2string (line 423) | int d2string(char *buf, size_t len, double value) {
  function vr_valid_port (line 460) | bool
  function _vr_sendn (line 473) | ssize_t
  function _vr_recvn (line 504) | ssize_t
  function vr_usec_now (line 535) | int64_t
  function vr_msec_now (line 556) | int64_t
  function vr_resolve_inet (line 562) | static int
  function vr_resolve_unix (line 632) | static int
  function vr_resolve (line 660) | int
  function vr_net_peer_to_string (line 670) | static int vr_net_peer_to_string(int fd, char *ip, size_t ip_len, int *p...
  function vr_net_format_addr (line 709) | static int vr_net_format_addr(char *buf, size_t buf_len, char *ip, int p...
  function vr_net_format_peer (line 715) | int vr_net_format_peer(int fd, char *buf, size_t buf_len) {
  function get_random_hex_chars (line 727) | void
  function stringmatchlen (line 802) | int stringmatchlen(const char *pattern, int patternLen,
  function stringmatch (line 924) | int stringmatch(const char *pattern, const char *string, int nocase) {
  function memrev16 (line 930) | void memrev16(void *p) {
  function memrev32 (line 940) | void memrev32(void *p) {
  function memrev64 (line 953) | void memrev64(void *p) {
  function intrev16 (line 970) | uint16_t intrev16(uint16_t v) {
  function intrev32 (line 975) | uint32_t intrev32(uint32_t v) {
  function intrev64 (line 980) | uint64_t intrev64(uint64_t v) {
  function memtoll (line 992) | long long memtoll(const char *p, int *err) {
  function bytesToHuman (line 1046) | void bytesToHuman(char *s, unsigned long long n) {
  function sds (line 1081) | sds getAbsolutePath(char *filename) {

FILE: src/vr_util.h
  type sockinfo (line 122) | struct sockinfo {
  type sockinfo (line 132) | struct sockinfo

FILE: src/vr_worker.c
  type darray (line 7) | struct darray
  type connswapunit (line 14) | struct connswapunit
  type connswapunit (line 20) | struct connswapunit
  type connswapunit (line 22) | struct connswapunit
  type connswapunit (line 34) | struct connswapunit
  function csui_free (line 59) | void
  function csul_push (line 67) | void
  type connswapunit (line 75) | struct connswapunit
  type connswapunit (line 78) | struct connswapunit
  function vr_worker_init (line 87) | int
  function vr_worker_deinit (line 154) | void
  function worker_get_next_idx (line 178) | int
  function dispatch_conn_new (line 185) | void
  function thread_event_process (line 217) | static void
  function setup_worker (line 318) | static int
  function workers_init (line 353) | int
  function workers_run (line 380) | int
  function workers_wait (line 396) | int
  function workers_deinit (line 412) | void
  function worker_before_sleep (line 426) | void
  function worker_cron (line 441) | int

FILE: src/vr_worker.h
  type vr_worker (line 4) | typedef struct vr_worker {
  type connswapunit (line 27) | struct connswapunit {
  type darray (line 33) | struct darray
  type connswapunit (line 40) | struct connswapunit
  type connswapunit (line 41) | struct connswapunit
  type connswapunit (line 43) | struct connswapunit
  type connswapunit (line 44) | struct connswapunit
  type aeEventLoop (line 50) | struct aeEventLoop
  type aeEventLoop (line 51) | struct aeEventLoop

FILE: src/vr_ziplist.c
  type zlentry (line 155) | typedef struct zlentry {
  function zipIntSize (line 180) | static unsigned int zipIntSize(unsigned char encoding) {
  function zipEncodeLength (line 195) | static unsigned int zipEncodeLength(unsigned char *p, unsigned char enco...
  function zipPrevEncodeLength (line 259) | static unsigned int zipPrevEncodeLength(unsigned char *p, unsigned int l...
  function zipPrevEncodeLengthForceLarge (line 277) | static void zipPrevEncodeLengthForceLarge(unsigned char *p, unsigned int...
  function zipPrevLenByteDiff (line 309) | static int zipPrevLenByteDiff(unsigned char *p, unsigned int len) {
  function zipRawEntryLength (line 316) | static unsigned int zipRawEntryLength(unsigned char *p) {
  function zipTryEncoding (line 325) | static int zipTryEncoding(unsigned char *entry, unsigned int entrylen, l...
  function zipSaveInteger (line 352) | static void zipSaveInteger(unsigned char *p, int64_t value, unsigned cha...
  function zipLoadInteger (line 382) | static int64_t zipLoadInteger(unsigned char *p, unsigned char encoding) {
  function zipEntry (line 414) | static void zipEntry(unsigned char *p, zlentry *e) {
  function ziplistGet (line 866) | unsigned int ziplistGet(unsigned char *p, unsigned char **sstr, unsigned...
  function ziplistCompare (line 913) | unsigned int ziplistCompare(unsigned char *p, unsigned char *sstr, unsig...
  function ziplistLen (line 1000) | unsigned int ziplistLen(unsigned char *zl) {
  function ziplistBlobLen (line 1018) | size_t ziplistBlobLen(unsigned char *zl) {
  function ziplistRepr (line 1022) | void ziplistRepr(unsigned char *zl) {
  function usec (line 1110) | static long long usec(void) {
  function stress (line 1116) | static void stress(int pos, int num, int maxsize, int dnum) {
  function randstring (line 1166) | static int randstring(char *target, unsigned int min, unsigned int max) {
  function verify (line 1192) | static void verify(unsigned char *zl, zlentry *e) {
  function ziplistTest (line 1209) | int ziplistTest(int argc, char **argv) {

FILE: src/vr_zipmap.c
  function zipmapDecodeLength (line 105) | static unsigned int zipmapDecodeLength(unsigned char *p) {
  function zipmapEncodeLength (line 116) | static unsigned int zipmapEncodeLength(unsigned char *p, unsigned int le...
  function zipmapRequiredLength (line 168) | static unsigned long zipmapRequiredLength(unsigned int klen, unsigned in...
  function zipmapRawKeyLength (line 178) | static unsigned int zipmapRawKeyLength(unsigned char *p) {
  function zipmapRawValueLength (line 185) | static unsigned int zipmapRawValueLength(unsigned char *p) {
  function zipmapRawEntryLength (line 197) | static unsigned int zipmapRawEntryLength(unsigned char *p) {
  function zipmapGet (line 334) | int zipmapGet(unsigned char *zm, unsigned char *key, unsigned int klen, ...
  function zipmapExists (line 345) | int zipmapExists(unsigned char *zm, unsigned char *key, unsigned int kle...
  function zipmapLen (line 350) | unsigned int zipmapLen(unsigned char *zm) {
  function zipmapBlobLen (line 367) | size_t zipmapBlobLen(unsigned char *zm) {

FILE: tests/vrabtest.c
  type config (line 41) | struct config {
  type config (line 61) | struct config
  type option (line 80) | struct option
  function vrt_show_usage (line 106) | static void
  function vrt_set_default_options (line 139) | static void
  function vrt_clean_options (line 165) | static void
  function vrt_get_options (line 189) | static int
  function vrt_daemonize (line 392) | static int vrt_daemonize(int dump_core)
  function abtest_server_init (line 493) | static int abtest_server_init(abtest_server *abs, char *address)
  function abtest_server_deinit (line 526) | static void abtest_server_deinit(abtest_server *abs)
  function get_backend_server_idx (line 542) | unsigned int get_backend_server_idx(abtest_group *abg, char *key, size_t...
  function abtest_server (line 556) | abtest_server *get_backend_server(abtest_group *abg, char *key, size_t k...
  function abtest_group_init (line 567) | static int abtest_group_init(abtest_group *abg, char *group_string)
  function abtest_group_deinit (line 629) | static void abtest_group_deinit(abtest_group *abg)
  function darray (line 643) | darray *abtest_groups_create(char *groups_string)
  function abtest_groups_destroy (line 680) | void abtest_groups_destroy(darray *abgs)
  function main (line 690) | int

FILE: tests/vrabtest.h
  type redisContext (line 6) | struct redisContext
  type redisAsyncContext (line 7) | struct redisAsyncContext
  type abtest_group (line 8) | struct abtest_group
  type conn_context (line 10) | typedef struct conn_context {
  type abtest_server (line 15) | typedef struct abtest_server {
  type abtest_group (line 24) | struct abtest_group
  type abtest_server (line 25) | typedef abtest_server *(*backend_server_t)(struct abtest_group*, char *,...
  type abtest_group (line 27) | typedef struct abtest_group {

FILE: tests/vrt_backend.c
  type task_data (line 26) | typedef struct task_data {
  function task_data_create (line 40) | static int task_data_create(void)
  function task_data_destroy (line 55) | static void task_data_destroy(task_data *td)
  function backend_conn_context_init (line 60) | static int backend_conn_context_init(conn_context *cc, char *host, int p...
  function backend_conn_context_deinit (line 73) | static void backend_conn_context_deinit(conn_context *cc)
  function connect_callback (line 86) | static void connect_callback(const redisAsyncContext *c, int status) {
  function disconnect_callback (line 97) | static void disconnect_callback(const redisAsyncContext *c, int status) {
  function scan_for_delete_callback (line 109) | static void scan_for_delete_callback(redisAsyncContext *c, void *r, void...
  function update_memory_callback (line 164) | static void update_memory_callback(redisAsyncContext *c, void *r, void *...
  function update_maxmemory_callback (line 178) | static void update_maxmemory_callback(redisAsyncContext *c, void *r, voi...
  function update_memory_info (line 210) | static void update_memory_info(darray *abgs)
  function check_memory_enough (line 226) | static void check_memory_enough(backend_thread *bt)
  function backend_thread_cron (line 264) | static int backend_thread_cron(aeEventLoop *eventLoop, long long id, voi...
  function backend_thread_init (line 293) | static int backend_thread_init(backend_thread *bt, char *test_target_gro...
  function backend_thread_deinit (line 344) | static void backend_thread_deinit(backend_thread *bt)
  function vrt_backend_init (line 375) | int vrt_backend_init(int threads_count, char *test_target_groups)
  function vrt_backend_deinit (line 396) | void vrt_backend_deinit(void)
  function vrt_start_backend (line 418) | int vrt_start_backend(void)
  function vrt_wait_backend (line 433) | int vrt_wait_backend(void)

FILE: tests/vrt_backend.h
  type abtest_group (line 6) | struct abtest_group
  type dlist (line 7) | struct dlist
  type dmtlist (line 8) | struct dmtlist
  type data_unit (line 9) | struct data_unit
  type aeEventLoop (line 10) | struct aeEventLoop
  type backend_thread (line 12) | typedef struct backend_thread {

FILE: tests/vrt_benchmark.c
  type config (line 31) | struct config {
  type benchmark_thread (line 67) | typedef struct benchmark_thread {
  type _benchmark_client (line 88) | struct _benchmark_client {
  type aeEventLoop (line 116) | struct aeEventLoop
  function freeClient (line 118) | static void freeClient(benchmark_client c) {
  function freeAllClients (line 141) | static void freeAllClients(dlist *clients) {
  function resetClient (line 151) | static void resetClient(benchmark_client c) {
  function randomizeClientKey (line 161) | static void randomizeClientKey(benchmark_client c) {
  function randomizeClientField (line 177) | static void randomizeClientField(benchmark_client c) {
  function clientDone (line 194) | static void clientDone(benchmark_client c) {
  function benchmark_thread_init (line 214) | static int benchmark_thread_init(benchmark_thread *bt, int requests, int...
  function benchmark_thread_deinit (line 254) | static void benchmark_thread_deinit(benchmark_thread *bt)
  function start_benchmark_threads_until_finish (line 283) | static int start_benchmark_threads_until_finish(void)
  function readHandlerMC (line 304) | static void readHandlerMC(aeEventLoop *el, int fd, void *privdata, int m...
  function readHandler (line 382) | static void readHandler(aeEventLoop *el, int fd, void *privdata, int mas...
  function writeHandler (line 458) | static void writeHandler(aeEventLoop *el, int fd, void *privdata, int ma...
  function benchmark_client (line 525) | static benchmark_client createClient(char *cmd, size_t len, benchmark_cl...
  function createMissingClients (line 688) | static void createMissingClients(benchmark_client c) {
  function compareLatency (line 707) | static int compareLatency(const void *a, const void *b) {
  function updateBenchmarkStats (line 711) | static void updateBenchmarkStats(void)
  function showLatencyReport (line 728) | static void showLatencyReport(void) {
  function benchmark (line 768) | static void benchmark(char *title, char *cmd, int len) {
  function parseOptions (line 808) | int parseOptions(int argc, const char **argv) {
  function showThroughput (line 975) | static int showThroughput(struct aeEventLoop *eventLoop, long long id, v...
  function test_is_selected (line 1001) | int test_is_selected(char *name) {
  function types_is_selected (line 1013) | int types_is_selected(char *name) {
  function set_requests_temporarily (line 1027) | void set_requests_temporarily(int num) {
  function retrieval_requests_to_original (line 1033) | void retrieval_requests_to_original() {
  function set_random_keys_temporarily (line 1043) | void set_random_keys_temporarily(int num) {
  function retrieval_random_keys_to_original (line 1051) | void retrieval_random_keys_to_original() {
  function test_redis (line 1060) | static int test_redis(int argc, const char **argv)
  function test_memcached (line 1387) | static int test_memcached(int argc, const char **argv)
  function main (line 1439) | int main(int argc, const char **argv) {

FILE: tests/vrt_check_data.c
  type check_data_thread (line 38) | typedef struct check_data_thread {
  type check_unit (line 57) | typedef struct check_unit {
  type data_checker (line 78) | typedef struct data_checker {
  function check_unit (line 102) | static check_unit *check_unit_create(void)
  function check_unit_destroy (line 131) | static void check_unit_destroy(check_unit *cunit)
  function check_conn_context_init (line 157) | static int check_conn_context_init(conn_context *cc, char *host, int port)
  function check_conn_context_deinit (line 170) | static void check_conn_context_deinit(conn_context *cc)
  function connect_callback (line 184) | static void connect_callback(const redisAsyncContext *c, int status) {
  function disconnect_callback (line 195) | static void disconnect_callback(const redisAsyncContext *c, int status) {
  function sort_replys_if_needed (line 207) | static int sort_replys_if_needed(check_unit *cunit)
  function check_replys_if_same (line 234) | static int check_replys_if_same(check_unit *cunit)
  function check_data_callback (line 254) | static void check_data_callback(redisAsyncContext *c, void *r, void *pri...
  function start_check_data (line 582) | static int start_check_data(char *key, size_t keylen, check_data_thread ...
  function scan_for_check_callback (line 616) | static void scan_for_check_callback(redisAsyncContext *c, void *r, void ...
  function one_check_data_thread_finished (line 665) | static void one_check_data_thread_finished(void)
  function all_check_data_threads_finished (line 670) | static int all_check_data_threads_finished(void)
  function check_data_thread_cron (line 682) | static int check_data_thread_cron(aeEventLoop *eventLoop, long long id, ...
  function check_data_thread_init (line 714) | static int check_data_thread_init(check_data_thread *cdt, char *test_tar...
  function check_data_thread_deinit (line 774) | static void check_data_thread_deinit(check_data_thread *cdt)
  function checking_data_or_not (line 818) | static int checking_data_or_not(void)
  function create_check_data_threads (line 834) | static int create_check_data_threads(void)
  function destroy_check_data_threads (line 914) | static void destroy_check_data_threads(void)
  function start_check_data_threads (line 937) | static int start_check_data_threads(void)
  function begin_check_data (line 956) | static int begin_check_data(void)
  function end_check_data (line 966) | static void end_check_data(void)
  function data_checker_cron (line 972) | static int data_checker_cron(aeEventLoop *eventLoop, long long id, void ...
  function vrt_data_checker_init (line 1006) | int vrt_data_checker_init(char *checker, char *test_target_groups)
  function vrt_data_checker_deinit (line 1054) | void vrt_data_checker_deinit(void)
  function vrt_start_data_checker (line 1089) | int vrt_start_data_checker(void)
  function vrt_wait_data_checker (line 1098) | int vrt_wait_data_checker(void)
  function test_if_need_pause (line 1107) | int test_if_need_pause(void)
  function test_can_continue (line 1117) | void test_can_continue(void)
  function test_need_to_pause (line 1125) | void test_need_to_pause(void)
  function one_produce_thread_paused (line 1130) | void one_produce_thread_paused(void)
  function one_dispatch_thread_paused (line 1135) | void one_dispatch_thread_paused(void)
  function one_backend_thread_paused (line 1140) | void one_backend_thread_paused(void)
  function all_produce_threads_paused (line 1145) | int all_produce_threads_paused(void)
  function all_dispatch_threads_paused (line 1157) | int all_dispatch_threads_paused(void)
  function all_backend_threads_paused (line 1169) | int all_backend_threads_paused(void)
  function all_threads_paused (line 1181) | int all_threads_paused(void)

FILE: tests/vrt_dispatch_data.c
  function get_total_tested_commands_count_per_cycle (line 36) | long long get_total_tested_commands_count_per_cycle(void)
  function get_total_reply_err_count_per_cycle (line 43) | long long get_total_reply_err_count_per_cycle(void)
  function reset_total_count_per_cycle (line 50) | void reset_total_count_per_cycle(void)
  type reply_unit (line 56) | typedef struct reply_unit {
  function show_replys_inconsistency_msg (line 63) | static void show_replys_inconsistency_msg(data_unit *du, redisReply *rep...
  function sort_replys_if_needed (line 115) | static int sort_replys_if_needed(reply_unit *ru)
  function check_replys_if_same (line 153) | static int check_replys_if_same(reply_unit *ru)
  type callback_data (line 174) | struct callback_data {
  function reply_callback (line 180) | static void reply_callback(redisAsyncContext *c, void *r, void *privdata) {
  function dispatch_thread_send_data (line 236) | static int dispatch_thread_send_data(dispatch_data_thread *ddt)
  function dispatch_data_thread_cron (line 291) | static int dispatch_data_thread_cron(aeEventLoop *eventLoop, long long i...
  function connect_callback (line 340) | static void connect_callback(const redisAsyncContext *c, int status) {
  function disconnect_callback (line 351) | static void disconnect_callback(const redisAsyncContext *c, int status) {
  function dispatch_conn_context_init (line 363) | static int dispatch_conn_context_init(conn_context *cc, char *host, int ...
  function dispatch_conn_context_deinit (line 376) | static void dispatch_conn_context_deinit(conn_context *cc)
  function dispatch_data_thread_init (line 389) | static int dispatch_data_thread_init(dispatch_data_thread *ddt, char *te...
  function dispatch_data_thread_deinit (line 456) | static void dispatch_data_thread_deinit(dispatch_data_thread *ddt)
  function vrt_dispatch_data_init (line 487) | int vrt_dispatch_data_init(int threads_count, char *test_target_groups, ...
  function vrt_dispatch_data_deinit (line 508) | void vrt_dispatch_data_deinit(void)
  function vrt_start_dispatch_data (line 530) | int vrt_start_dispatch_data(void)
  function vrt_wait_dispatch_data (line 545) | int vrt_wait_dispatch_data(void)
  function data_dispatch (line 561) | int data_dispatch(data_unit *du)

FILE: tests/vrt_dispatch_data.h
  type abtest_group (line 6) | struct abtest_group
  type dlist (line 7) | struct dlist
  type dmtqueue (line 8) | struct dmtqueue
  type data_unit (line 9) | struct data_unit
  type aeEventLoop (line 10) | struct aeEventLoop
  type dispatch_data_thread (line 12) | typedef struct dispatch_data_thread {
  type data_unit (line 49) | struct data_unit

FILE: tests/vrt_produce_data.c
  type produce_thread (line 27) | typedef struct produce_thread {
  function sds (line 60) | static sds get_random_cached_key(produce_scheme *ps, data_producer *dp)
  function get_random_int (line 66) | static int get_random_int(void)
  function get_random_unsigned_int (line 75) | static unsigned int get_random_unsigned_int(void)
  function get_random_char (line 80) | static char get_random_char(void)
  function sds (line 86) | static sds get_random_key(void)
  function sds (line 104) | static sds get_random_string(void)
  function sds (line 120) | static sds get_random_float_str(void)
  function sds (line 146) | static sds *get_random_zset_range_min_max_str(int range_type)
  function get_random_field_len (line 256) | static unsigned int get_random_field_len(void)
  function sds (line 261) | static sds get_random_key_with_hit_ratio(produce_scheme *ps, data_produc...
  function nck_when_noerror (line 277) | static int nck_when_noerror(redisReply *reply)
  function nck_when_ok (line 288) | static int nck_when_ok(redisReply *reply)
  function nck_when_str (line 300) | static int nck_when_str(redisReply *reply)
  function nck_when_unsigned_integer (line 311) | static int nck_when_unsigned_integer(redisReply *reply)
  function nck_when_nonzero_unsigned_integer (line 323) | static int nck_when_nonzero_unsigned_integer(redisReply *reply)
  function nck_when_zero_or_one (line 335) | static int nck_when_zero_or_one(redisReply *reply)
  function nck_when_one (line 347) | static int nck_when_one(redisReply *reply)
  function data_unit (line 361) | static data_unit *get_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 375) | static data_unit *set_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 390) | static data_unit *setnx_cmd_producer(data_producer *dp, produce_scheme *ps)
  function setnx_cmd_nck (line 406) | static int setnx_cmd_nck(redisReply *reply)
  function data_unit (line 418) | static data_unit *setex_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 434) | static data_unit *psetex_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 450) | static data_unit *del_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 464) | static data_unit *expire_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 479) | static data_unit *expireat_cmd_producer(data_producer *dp, produce_schem...
  function data_unit (line 494) | static data_unit *exists_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 508) | static data_unit *ttl_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 522) | static data_unit *pttl_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 536) | static data_unit *incr_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 550) | static data_unit *decr_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 564) | static data_unit *incrby_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 579) | static data_unit *decrby_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 594) | static data_unit *append_cmd_producer(data_producer *dp, produce_scheme ...
  function append_cmd_nck (line 610) | static int append_cmd_nck(redisReply *reply)
  function data_unit (line 621) | static data_unit *strlen_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 635) | static data_unit *getset_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 650) | static data_unit *incrbyfloat_cmd_producer(data_producer *dp, produce_sc...
  function data_unit (line 665) | static data_unit *setbit_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 685) | static data_unit *getbit_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 700) | static data_unit *setrange_cmd_producer(data_producer *dp, produce_schem...
  function data_unit (line 716) | static data_unit *getrange_cmd_producer(data_producer *dp, produce_schem...
  function data_unit (line 732) | static data_unit *bitcount_cmd_producer(data_producer *dp, produce_schem...
  function data_unit (line 753) | static data_unit *bitpos_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 784) | static data_unit *mget_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 798) | static data_unit *mset_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 813) | static data_unit *hset_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 829) | static data_unit *hget_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 844) | static data_unit *hlen_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 858) | static data_unit *hdel_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 878) | static data_unit *hexists_cmd_producer(data_producer *dp, produce_scheme...
  function data_unit (line 893) | static data_unit *hkeys_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 907) | static data_unit *hvals_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 921) | static data_unit *hgetall_cmd_producer(data_producer *dp, produce_scheme...
  function data_unit (line 935) | static data_unit *hincrby_cmd_producer(data_producer *dp, produce_scheme...
  function data_unit (line 951) | static data_unit *hincrbyfloat_cmd_producer(data_producer *dp, produce_s...
  function data_unit (line 967) | static data_unit *hmget_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 987) | static data_unit *hmset_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1008) | static data_unit *hsetnx_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 1024) | static data_unit *hstrlen_cmd_producer(data_producer *dp, produce_scheme...
  function data_unit (line 1039) | static data_unit *rpush_cmd_producer(data_producer *dp, produce_scheme *ps)
  function rpush_cmd_nck (line 1060) | static int rpush_cmd_nck(redisReply *reply)
  function data_unit (line 1071) | static data_unit *lpush_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1092) | static data_unit *lrange_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 1108) | static data_unit *rpop_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1122) | static data_unit *lpop_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1136) | static data_unit *llen_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1150) | static data_unit *lrem_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1166) | static data_unit *ltrim_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1182) | static data_unit *lindex_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 1197) | static data_unit *lset_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1213) | static data_unit *sadd_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1233) | static data_unit *smembers_cmd_producer(data_producer *dp, produce_schem...
  function data_unit (line 1247) | static data_unit *scard_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1261) | static data_unit *srem_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1281) | static data_unit *sismember_cmd_producer(data_producer *dp, produce_sche...
  function data_unit (line 1296) | static data_unit *sunion_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 1310) | static data_unit *sdiff_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1324) | static data_unit *sinter_cmd_producer(data_producer *dp, produce_scheme ...
  function lpush_cmd_nck (line 1339) | static int lpush_cmd_nck(redisReply *reply)
  function data_unit (line 1350) | static data_unit *zadd_cmd_producer(data_producer *dp, produce_scheme *ps)
  function zadd_cmd_nck (line 1373) | static int zadd_cmd_nck(redisReply *reply)
  function data_unit (line 1384) | static data_unit *zincrby_cmd_producer(data_producer *dp, produce_scheme...
  function zincrby_cmd_nck (line 1402) | static int zincrby_cmd_nck(redisReply *reply)
  function data_unit (line 1413) | static data_unit *zrange_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 1438) | static data_unit *zrevrange_cmd_producer(data_producer *dp, produce_sche...
  function data_unit (line 1463) | static data_unit *zrem_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1484) | static data_unit *zcard_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1498) | static data_unit *zcount_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 1516) | static data_unit *zrangebyscore_cmd_producer(data_producer *dp, produce_...
  function data_unit (line 1558) | static data_unit *zrevrangebyscore_cmd_producer(data_producer *dp, produ...
  function data_unit (line 1600) | static data_unit *zrank_cmd_producer(data_producer *dp, produce_scheme *ps)
  function data_unit (line 1615) | static data_unit *zrevrank_cmd_producer(data_producer *dp, produce_schem...
  function data_unit (line 1630) | static data_unit *zscore_cmd_producer(data_producer *dp, produce_scheme ...
  function data_unit (line 1645) | static data_unit *zremrangebyscore_cmd_producer(data_producer *dp, produ...
  function data_unit (line 1663) | static data_unit *zremrangebyrank_cmd_producer(data_producer *dp, produc...
  function data_unit (line 1681) | static data_unit *zremrangebylex_cmd_producer(data_producer *dp, produce...
  function data_unit (line 1782) | data_unit *data_unit_get(void)
  function data_unit_put (line 1793) | void data_unit_put(data_unit *du)
  function produce_scheme (line 1805) | static produce_scheme *produce_scheme_create(long long max_cached_keys, ...
  function produce_scheme_destroy (line 1860) | static void produce_scheme_destroy(produce_scheme *ps)
  function get_kcp_idx (line 1876) | static unsigned int get_kcp_idx(int type)
  function set_non_empty_kcps_idx (line 1910) | static void set_non_empty_kcps_idx(void)
  function key_cache_array (line 1935) | key_cache_array *kcp_get_from_ps(produce_scheme *ps, data_producer *dp)
  function vrt_produce_threads_init (line 1963) | static int vrt_produce_threads_init(unsigned int produce_threads_count,
  function vrt_produce_threads_deinit (line 1981) | static void vrt_produce_threads_deinit(void)
  function add_to_needed_cmd_type_producer (line 2041) | static int add_to_needed_cmd_type_producer(data_producer *dp)
  function vrt_produce_data_init (line 2051) | int vrt_produce_data_init(int key_length_range_min,int key_length_range_...
  function vrt_produce_data_deinit (line 2160) | void vrt_produce_data_deinit(void)
  function vrt_start_produce_data (line 2168) | int vrt_start_produce_data(void)
  function vrt_wait_produce_data (line 2184) | int vrt_wait_produce_data(void)
  function sds (line 2238) | sds get_one_key_from_data_unit(data_unit *du)
  function print_producer_command (line 2256) | void print_producer_command(data_unit *du)

FILE: tests/vrt_produce_data.h
  type data_producer (line 50) | struct data_producer
  type produce_scheme (line 51) | struct produce_scheme
  type key_cache_array (line 52) | struct key_cache_array
  type data_unit (line 54) | struct data_unit
  type data_producer (line 54) | struct data_producer
  type produce_scheme (line 54) | struct produce_scheme
  type data_producer (line 55) | struct data_producer
  type redisReply (line 56) | struct redisReply
  type data_producer (line 57) | typedef struct data_producer {
  type data_unit (line 75) | typedef struct data_unit {
  type produce_scheme (line 85) | typedef struct produce_scheme {
  type key_cache_array (line 100) | struct key_cache_array

FILE: tests/vrt_public.c
  function set_execute_file (line 35) | void set_execute_file(char *file)
  function sds (line 40) | static sds vire_conf_create(char *dir, int port)
  function vire_instance (line 69) | vire_instance *vire_instance_create(int port)
  function vire_instance_destroy (line 112) | void vire_instance_destroy(vire_instance *vi)
  function vire_server_run (line 146) | int vire_server_run(vire_instance *vi)
  function vire_server_stop (line 201) | void vire_server_stop(vire_instance *vi)
  function create_work_dir (line 242) | int create_work_dir(void)
  function destroy_work_dir (line 259) | int destroy_work_dir(void)
  function get_next_port (line 275) | static int get_next_port(void)
  function vire_instance (line 283) | vire_instance *start_one_vire_instance(void)
  function show_test_result (line 312) | void show_test_result(int result,char *test_content,char *errmsg)
  function key_cache_array (line 323) | key_cache_array *key_cache_array_create(long long max_pool_size)
  function key_cache_array_destroy (line 348) | void key_cache_array_destroy(key_cache_array *kca)
  function key_cache_array_input (line 366) | int key_cache_array_input(key_cache_array *kca, char *key, size_t keylen)
  function sds (line 385) | sds key_cache_array_random(key_cache_array *kca)
  function get_longlong_from_info_reply (line 412) | long long get_longlong_from_info_reply(redisReply *reply, char *name)
  function redisReply (line 450) | redisReply *steal_hiredis_redisreply(redisReply *r)
  function check_two_replys_if_same (line 474) | int check_two_replys_if_same(redisReply *reply1, redisReply *reply2)
  type sort_unit (line 514) | struct sort_unit {
  function element_cmp_multi_step (line 521) | static int element_cmp_multi_step(const void *ele1,const void *ele2)
  function sort_array_by_step (line 534) | int sort_array_by_step(void **element, size_t elements,
  function reply_string_binary_compare (line 581) | int reply_string_binary_compare(const void *r1,const void *r2)
  function parse_command_types (line 594) | int parse_command_types(char *command_types_str)
  function darray (line 637) | darray *parse_command_list(char *command_list_str)

FILE: tests/vrt_public.h
  type darray (line 14) | struct darray
  type key_cache_pool (line 15) | struct key_cache_pool
  type vire_instance (line 87) | typedef struct vire_instance {
  type key_cache_array (line 116) | typedef struct key_cache_array {
  type darray (line 137) | struct darray

FILE: tests/vrt_simple.c
  function simple_test_cmd_get_set (line 20) | static int simple_test_cmd_get_set(vire_instance *vi)
  function simple_test_cmd_setnx (line 56) | static int simple_test_cmd_setnx(vire_instance *vi)
  function simple_test_cmd_setex (line 104) | static int simple_test_cmd_setex(vire_instance *vi)
  function simple_test_cmd_psetex (line 147) | static int simple_test_cmd_psetex(vire_instance *vi)
  function simple_test_cmd_incr (line 190) | static int simple_test_cmd_incr(vire_instance *vi)
  function simple_test_cmd_decr (line 255) | static int simple_test_cmd_decr(vire_instance *vi)
  function simple_test_cmd_incrby (line 320) | static int simple_test_cmd_incrby(vire_instance *vi)
  function simple_test_cmd_decrby (line 387) | static int simple_test_cmd_decrby(vire_instance *vi)
  function simple_test_cmd_append (line 454) | static int simple_test_cmd_append(vire_instance *vi)
  function simple_test_cmd_strlen (line 508) | static int simple_test_cmd_strlen(vire_instance *vi)
  function simple_test_cmd_getset (line 544) | static int simple_test_cmd_getset(vire_instance *vi)
  function simple_test_cmd_incrbyfloat (line 587) | static int simple_test_cmd_incrbyfloat(vire_instance *vi)
  function simple_test_cmd_getbit_setbit_bitcount (line 649) | static int simple_test_cmd_getbit_setbit_bitcount(vire_instance *vi)
  function simple_test_cmd_getrange_setrange (line 701) | static int simple_test_cmd_getrange_setrange(vire_instance *vi)
  function simple_test_cmd_bitpos (line 753) | static int simple_test_cmd_bitpos(vire_instance *vi)
  function simple_test_cmd_mget_mset (line 826) | static int simple_test_cmd_mget_mset(vire_instance *vi)
  type test_hash_member (line 911) | struct test_hash_member {
  function test_hash_member_length (line 916) | static int test_hash_member_length(struct test_hash_member **thms)
  function test_hash_members_destroy (line 925) | static void test_hash_members_destroy(struct test_hash_member **thms)
  type test_hash_member (line 937) | struct test_hash_member
  type test_hash_member (line 943) | struct test_hash_member
  type test_hash_member (line 966) | struct test_hash_member
  type test_hash_member (line 968) | struct test_hash_member
  function simple_test_hash_encode (line 1027) | static int simple_test_hash_encode(vire_instance *vi)
  function simple_test_cmd_hget_hset (line 1071) | static int simple_test_cmd_hget_hset(vire_instance *vi)
  function simple_test_cmd_hlen (line 1141) | static int simple_test_cmd_hlen(vire_instance *vi)
  function simple_test_cmd_hdel (line 1206) | static int simple_test_cmd_hdel(vire_instance *vi)
  function simple_test_cmd_pfadd_pfcount (line 1299) | static int simple_test_cmd_pfadd_pfcount(vire_instance *vi)
  function simple_test (line 1354) | int simple_test(void)

FILE: tests/vrt_util.c
  function vrt_assert (line 18) | void
  function vrt_vscnprintf (line 27) | int
  function vrt_scnprintf (line 55) | int
  function _test_log_error (line 68) | void
  function _test_log_out (line 92) | void
  function vrt_usec_now (line 117) | int64_t
  function vrt_msec_now (line 137) | int64_t
  function vrt_sec_now (line 146) | int64_t
  function sds (line 159) | sds getAbsolutePath(char *filename) {
  function digits10 (line 206) | uint32_t digits10(uint64_t v) {
  function sdigits10 (line 227) | uint32_t sdigits10(int64_t v) {
  function ll2string (line 249) | int ll2string(char* dst, size_t dstlen, long long svalue) {
  function string2ll (line 306) | int string2ll(const char *s, size_t slen, long long *value) {
  function string2l (line 372) | int string2l(const char *s, size_t slen, long *lval) {
  function d2string (line 387) | int d2string(char *buf, size_t len, double value) {
  function create_dir (line 424) | int create_dir(char *path)
  function destroy_dir (line 433) | int destroy_dir(char *path)
  function get_pid_from_reply (line 469) | int get_pid_from_reply(redisContext *redisctx, char *host, int port)
  function sds (line 594) | sds get_host_port_from_address_string(char *address, int *port)

FILE: tests/vrt_util.h
  type redisContext (line 74) | struct redisContext

FILE: tests/vrtest.c
  type config (line 16) | struct config {
  type config (line 23) | struct config
  type option (line 28) | struct option
  function vr_show_usage (line 38) | static void
  function vr_set_default_options (line 53) | static void
  function vr_get_options (line 59) | static int
  function main (line 115) | int
Condensed preview — 174 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,761K chars).
[
  {
    "path": ".gitignore",
    "chars": 639,
    "preview": "# pyc\n*.pyc\n\n# Compiled Object files\n*.lo\n*.o\n\n# Compiled Dynamic libraries\n*.so\n\n# Compiled Static libraries\n*.la\n*.a\n\n"
  },
  {
    "path": "ChangeLog",
    "chars": 1863,
    "preview": " 2016-10-25  deep011  <diguo58@gmail.com>\n    * vire: version 1.0.0 release\n      vire (pronounced \"vip-redis\") is a mul"
  },
  {
    "path": "LICENSE",
    "chars": 10173,
    "preview": "\n                                 Apache License\n                           Version 2.0, January 2004\n                  "
  },
  {
    "path": "Makefile.am",
    "chars": 210,
    "preview": "MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.h.in config.h.in~ stamp-h.in\n\nACLOCAL_AMFLAGS = -I m4\n\nSU"
  },
  {
    "path": "NOTICE",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "README.md",
    "chars": 2874,
    "preview": "# vire\n\n**vire** (pronounced \"vip-redis\") is a multithread redis(based on redis-3.2.0) maintains in vipshop.\n\n### QQ交流群:"
  },
  {
    "path": "conf/vire.conf",
    "chars": 8244,
    "preview": "################################## NETWORK #####################################\n\n# By default, if no \"bind\" configurati"
  },
  {
    "path": "configure.ac",
    "chars": 7381,
    "preview": "# Define the package version numbers and the bug reporting address\nm4_define([VR_MAJOR], 1)\nm4_define([VR_MINOR], 0)\nm4_"
  },
  {
    "path": "dep/.gitignore",
    "chars": 9,
    "preview": "!*.tar.gz"
  },
  {
    "path": "dep/Makefile.am",
    "chars": 159,
    "preview": "SUBDIRS = jemalloc-4.2.0 hiredis-0.13.3 himemcached-0.1.0 util dhashkit dmalloc ae sds dlist darray\n\nEXTRA_DIST = jemall"
  },
  {
    "path": "dep/ae/Makefile.am",
    "chars": 407,
    "preview": "MAINTAINERCLEANFILES = Makefile.in\n\nAM_CPPFLAGS =\nif !OS_SOLARIS\nAM_CPPFLAGS += -D_GNU_SOURCE\nendif\nAM_CPPFLAGS += -I $("
  },
  {
    "path": "dep/ae/ae.c",
    "chars": 15717,
    "preview": "/* A simple event-driven programming library. Originally I wrote this code\n * for the Jim's event-loop (Jim is a Tcl int"
  },
  {
    "path": "dep/ae/ae.h",
    "chars": 4787,
    "preview": "/* A simple event-driven programming library. Originally I wrote this code\n * for the Jim's event-loop (Jim is a Tcl int"
  },
  {
    "path": "dep/ae/ae_epoll.c",
    "chars": 4844,
    "preview": "/* Linux epoll(2) based ae.c module\n *\n * Copyright (c) 2009-2012, Salvatore Sanfilippo <antirez at gmail dot com>\n * Al"
  },
  {
    "path": "dep/ae/ae_evport.c",
    "chars": 10938,
    "preview": "/* ae.c module for illumos event ports.\n *\n * Copyright (c) 2012, Joyent, Inc. All rights reserved.\n *\n * Redistribution"
  },
  {
    "path": "dep/ae/ae_kqueue.c",
    "chars": 4565,
    "preview": "/* Kqueue(2)-based ae.c module\n *\n * Copyright (C) 2009 Harish Mallipeddi - harish.mallipeddi@gmail.com\n * All rights re"
  },
  {
    "path": "dep/ae/ae_select.c",
    "chars": 3803,
    "preview": "/* Select()-based ae.c module.\n *\n * Copyright (c) 2009-2012, Salvatore Sanfilippo <antirez at gmail dot com>\n * All rig"
  },
  {
    "path": "dep/darray/Makefile.am",
    "chars": 427,
    "preview": "MAINTAINERCLEANFILES = Makefile.in\n\nAM_CPPFLAGS =\nif !OS_SOLARIS\nAM_CPPFLAGS += -D_GNU_SOURCE\nendif\nAM_CPPFLAGS += -I $("
  },
  {
    "path": "dep/darray/darray.c",
    "chars": 2592,
    "preview": "#include <stdlib.h>\n\n#include <dmalloc.h>\n\n#include <darray.h>\n\ndarray *\ndarray_create(unsigned long long n, size_t size"
  },
  {
    "path": "dep/darray/darray.h",
    "chars": 1357,
    "preview": "#ifndef _DARRAY_H_\n#define _DARRAY_H_\n\ntypedef int (*darray_compare_t)(const void *, const void *);\ntypedef int (*darray"
  },
  {
    "path": "dep/dhashkit/Makefile.am",
    "chars": 406,
    "preview": "MAINTAINERCLEANFILES = Makefile.in\n\nAM_CFLAGS = -Wall -Wshadow\nAM_CFLAGS += -Wno-unused-parameter -Wno-unused-value\n\nnoi"
  },
  {
    "path": "dep/dhashkit/dcrc16.c",
    "chars": 2407,
    "preview": "#include <dhashkit.h>\n\nstatic const uint16_t crc16tab[256] = {\n  0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6,"
  },
  {
    "path": "dep/dhashkit/dcrc32.c",
    "chars": 4036,
    "preview": "#include <dhashkit.h>\n\nstatic const uint32_t crc32tab[256] = {\n    0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,\n    0"
  },
  {
    "path": "dep/dhashkit/dfnv.c",
    "chars": 1271,
    "preview": "#include <dhashkit.h>\n\nstatic uint64_t FNV_64_INIT = UINT64_C(0xcbf29ce484222325);\nstatic uint64_t FNV_64_PRIME = UINT64"
  },
  {
    "path": "dep/dhashkit/dhashkit.h",
    "chars": 2863,
    "preview": "#ifndef _DHASHKIT_H_\n#define _DHASHKIT_H_\n\n#include <stdint.h>\n#include <stdio.h>\n\n#include <sys/types.h>\n\nstruct contin"
  },
  {
    "path": "dep/dhashkit/dhsieh.c",
    "chars": 1459,
    "preview": "#include <dhashkit.h>\n\n#undef get16bits\n#if (defined(__GNUC__) && defined(__i386__))\n#define get16bits(d) (*((const uint"
  },
  {
    "path": "dep/dhashkit/djenkins.c",
    "chars": 6319,
    "preview": "#include <dhashkit.h>\n\n#define hashsize(n) ((uint32_t)1<<(n))\n#define hashmask(n) (hashsize(n)-1)\n#define rot(x,k) (((x)"
  },
  {
    "path": "dep/dhashkit/dketama.c",
    "chars": 1545,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <math.h>\n\n#include <dhashkit.h>\n\n#define KETAMA_CONTINUUM_ADDITION   10 "
  },
  {
    "path": "dep/dhashkit/dmd5.c",
    "chars": 8847,
    "preview": "#include <string.h>\n\n#include <dhashkit.h>\n\n/*\n * This is an OpenSSL-compatible implementation of the RSA Data Security,"
  },
  {
    "path": "dep/dhashkit/dmodula.c",
    "chars": 428,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n\n#include <dhashkit.h>\n\n#define MODULA_CONTINUUM_ADDITION   10  /* # extra slots "
  },
  {
    "path": "dep/dhashkit/dmurmur.c",
    "chars": 1677,
    "preview": "/*\n * \"Murmur\" hash provided by Austin, tanjent@gmail.com\n * http://murmurhash.googlepages.com/\n *\n * Note - This code m"
  },
  {
    "path": "dep/dhashkit/done_at_a_time.c",
    "chars": 712,
    "preview": "/*\n * HashKit\n * Copyright (C) 2009 Brian Aker\n * All rights reserved.\n *\n * Use and distribution licensed under the BSD"
  },
  {
    "path": "dep/dhashkit/drandom.c",
    "chars": 432,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n\n#include <dhashkit.h>\n\n#define RANDOM_CONTINUUM_ADDITION   10  /* # extra slots "
  },
  {
    "path": "dep/dhashkit/dsha1.c",
    "chars": 6646,
    "preview": "\n/* from valgrind tests */\n\n/* ================ sha1.c ================ */\n/*\nSHA-1 in C\nBy Steve Reid <steve@edmweb.com"
  },
  {
    "path": "dep/dlist/Makefile.am",
    "chars": 544,
    "preview": "MAINTAINERCLEANFILES = Makefile.in\n\nAM_CPPFLAGS =\nif !OS_SOLARIS\nAM_CPPFLAGS += -D_GNU_SOURCE\nendif\nAM_CPPFLAGS += -I $("
  },
  {
    "path": "dep/dlist/dlist.c",
    "chars": 8431,
    "preview": "#include <stdlib.h>\n\n#include <dmalloc.h>\n\n#include <dlist.h>\n\n/* Create a new list. The created list can be freed with\n"
  },
  {
    "path": "dep/dlist/dlist.h",
    "chars": 1916,
    "preview": "#ifndef _DLIST_H__\n#define _DLIST_H__\n\n/* Node, List, and Iterator are the only data structures used currently. */\n\ntype"
  },
  {
    "path": "dep/dlist/dlockqueue.c",
    "chars": 2962,
    "preview": "#include <pthread.h>\n#include <stdlib.h>\n#include <stdio.h>\n\n#include <dmalloc.h>\n\n#include <dlist.h>\n#include <dmtqueue"
  },
  {
    "path": "dep/dlist/dlockqueue.h",
    "chars": 395,
    "preview": "#ifndef _DLOCKQUEUE_H_\n#define _DLOCKQUEUE_H_\n\nstruct dlist;\n\ntypedef struct dlockqueue{\n    struct dlist *l;\n    long l"
  },
  {
    "path": "dep/dlist/dmtqueue.c",
    "chars": 1903,
    "preview": "#include <stdlib.h>\n\n#include <dmalloc.h>\n\n#include <dlist.h>\n#include <dmtqueue.h>\n#include <dlockqueue.h>\n\n/******** m"
  },
  {
    "path": "dep/dlist/dmtqueue.h",
    "chars": 1034,
    "preview": "#ifndef _DMTQUEUE_H_\n#define _DMTQUEUE_H_\n\n#define MAX_LENGTH_POLICY_REJECT        0\n#define MAX_LENGTH_POLICY_EVICT_HEA"
  },
  {
    "path": "dep/dmalloc/Makefile.am",
    "chars": 393,
    "preview": "MAINTAINERCLEANFILES = Makefile.in\n\nAM_CPPFLAGS =\nif !OS_SOLARIS\nAM_CPPFLAGS += -D_GNU_SOURCE\nendif\nAM_CPPFLAGS += -I $("
  },
  {
    "path": "dep/dmalloc/dmalloc.c",
    "chars": 9887,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <errno.h>\n#include <pthread.h>\n\n#include <unistd.h>\n"
  },
  {
    "path": "dep/dmalloc/dmalloc.h",
    "chars": 1966,
    "preview": "#ifndef _DMALLOC_H_\n#define _DMALLOC_H_\n\n#ifdef HAVE_CONFIG_H\n# include <config.h>\n#endif\n\n#include <dspecialconfig.h>\n\n"
  },
  {
    "path": "dep/himemcached-0.1.0/Makefile.am",
    "chars": 353,
    "preview": "MAINTAINERCLEANFILES = Makefile.in\n\nAM_CFLAGS = -Wall -Wshadow\nAM_CFLAGS += -Wno-unused-parameter -Wno-unused-value\n\nnoi"
  },
  {
    "path": "dep/himemcached-0.1.0/himcdep/sds.c",
    "chars": 33899,
    "preview": "/* SDS (Simple Dynamic Strings), A C dynamic strings library.\n *\n * Copyright (c) 2006-2014, Salvatore Sanfilippo <antir"
  },
  {
    "path": "dep/himemcached-0.1.0/himcdep/sds.h",
    "chars": 3748,
    "preview": "/* SDS (Simple Dynamic Strings), A C dynamic strings library.\n *\n * Copyright (c) 2006-2014, Salvatore Sanfilippo <antir"
  },
  {
    "path": "dep/himemcached-0.1.0/himcread.c",
    "chars": 21714,
    "preview": "#include <string.h>\n#include <stdlib.h>\n#ifndef _MSC_VER\n#include <unistd.h>\n#endif\n#include <assert.h>\n#include <errno."
  },
  {
    "path": "dep/himemcached-0.1.0/himcread.h",
    "chars": 2548,
    "preview": "#ifndef _HIMC_READ_H_\n#define _HIMC_READ_H_\n#include <stdio.h> /* for size_t */\n\n#include <himcread.h>\n\n#define MC_ERR  "
  },
  {
    "path": "dep/himemcached-0.1.0/himemcached.c",
    "chars": 24014,
    "preview": "#include <stdlib.h>\n#include <errno.h>\n#include <assert.h>\n\n#include \"himemcached.h\"\n\n#define REQ_TYPE_UNKNOWN        0\n"
  },
  {
    "path": "dep/himemcached-0.1.0/himemcached.h",
    "chars": 3391,
    "preview": "#ifndef _HIMEMCACHED_H_\n#define _HIMEMCACHED_H_\n\n#include \"himcread.h\"\n#include \"himcdep/sds.h\"\n\n#define HIMC_MAJOR 0\n#d"
  },
  {
    "path": "dep/hiredis-0.13.3/.gitignore",
    "chars": 1,
    "preview": "\n"
  },
  {
    "path": "dep/jemalloc-4.2.0/.gitignore",
    "chars": 1,
    "preview": "\n"
  },
  {
    "path": "dep/sds/Makefile.am",
    "chars": 454,
    "preview": "MAINTAINERCLEANFILES = Makefile.in\n\nAM_CPPFLAGS =\nif !OS_SOLARIS\nAM_CPPFLAGS += -D_GNU_SOURCE\nendif\nAM_CPPFLAGS += -I $("
  },
  {
    "path": "dep/sds/sds.c",
    "chars": 40150,
    "preview": "/* SDSLib 2.0 -- A C dynamic strings library\n *\n * Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot c"
  },
  {
    "path": "dep/sds/sds.h",
    "chars": 8956,
    "preview": "/* SDSLib 2.0 -- A C dynamic strings library\n *\n * Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot c"
  },
  {
    "path": "dep/sds/sdsalloc.h",
    "chars": 2093,
    "preview": "/* SDSLib 2.0 -- A C dynamic strings library\n *\n * Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot c"
  },
  {
    "path": "dep/util/Makefile.am",
    "chars": 290,
    "preview": "MAINTAINERCLEANFILES = Makefile.in\n\nAM_CFLAGS = -Wall -Wshadow\nAM_CFLAGS += -Wno-unused-parameter -Wno-unused-value\n\nnoi"
  },
  {
    "path": "dep/util/dlog.c",
    "chars": 7395,
    "preview": "#include <stdlib.h>\n#include <stdarg.h>\n#include <unistd.h>\n#include <ctype.h>\n#include <time.h>\n#include <sys/stat.h>\n#"
  },
  {
    "path": "dep/util/dlog.h",
    "chars": 5330,
    "preview": "#ifndef _DLOG_H_\n#define _DLOG_H_\n\n#ifdef HAVE_CONFIG_H\n# include <config.h>\n#endif\n\nstruct logger {\n    char *name;  /*"
  },
  {
    "path": "dep/util/dspecialconfig.h",
    "chars": 1334,
    "preview": "#ifndef _DSPECIALCONFIG_H_\n#define _DSPECIALCONFIG_H_\n\n#ifdef __APPLE__\n#include <AvailabilityMacros.h>\n#endif\n\n#ifdef _"
  },
  {
    "path": "dep/util/dutil.c",
    "chars": 11413,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n#include <string.h>\n#include <unistd.h>\n#include <fcntl.h>\n#i"
  },
  {
    "path": "dep/util/dutil.h",
    "chars": 5704,
    "preview": "#ifndef _DUTIL_H_\n#define _DUTIL_H_\n\n#include <stdarg.h>\n\n#include <dspecialconfig.h>\n\n#define UNUSED(x) (void)(x)\n\n#def"
  },
  {
    "path": "m4/.gitignore",
    "chars": 47,
    "preview": "# Ignore everything\n*\n\n# Except me\n!.gitignore\n"
  },
  {
    "path": "notes/c-styleguide.txt",
    "chars": 15522,
    "preview": "- No literal tabs. Expand tabs to 4 spaces.\n- Indentation is 4 spaces.\n- No more than 3 levels of indentation, otherwise"
  },
  {
    "path": "notes/debug.txt",
    "chars": 6283,
    "preview": "- strace\n  strace -o strace.txt -ttT -s 1024 -p `pgrep nutcracker`\n\n- libyaml (yaml-0.1.4)\n\n  - yaml tokens:\n\n  0  YAML_"
  },
  {
    "path": "notes/socket.txt",
    "chars": 6283,
    "preview": "- int listen(int sockfd, int backlog);\n\n  Linux: The  backlog  argument defines the maximum length to which the\n  queue "
  },
  {
    "path": "scripts/.gitignore",
    "chars": 18,
    "preview": "*.pyc\n*.out\n*.log\n"
  },
  {
    "path": "src/Makefile.am",
    "chars": 3284,
    "preview": "MAINTAINERCLEANFILES = Makefile.in\n\nAM_CPPFLAGS =\nif !OS_SOLARIS\nAM_CPPFLAGS += -D_GNU_SOURCE\nendif\nAM_CPPFLAGS += -I $("
  },
  {
    "path": "src/vr.c",
    "chars": 13721,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <unistd.h>\n#include <signal.h>\n#include <getopt.h>\n#include <fcntl.h>\n#i"
  },
  {
    "path": "src/vr_aof.c",
    "chars": 7643,
    "preview": "#include <vr_core.h>\n\n/* Return the current size of the AOF rewrite buffer. */\nunsigned long aofRewriteBufferSize(void) "
  },
  {
    "path": "src/vr_aof.h",
    "chars": 1570,
    "preview": "#ifndef _VR_AOF_H_\n#define _VR_AOF_H_\n\n/* AOF states */\n#define AOF_OFF 0             /* AOF is off */\n#define AOF_ON 1 "
  },
  {
    "path": "src/vr_backend.c",
    "chars": 3503,
    "preview": "#include <vr_core.h>\n\n/* Which thread we assigned a connection to most recently. */\nstatic int num_backend_threads;\n\nstr"
  },
  {
    "path": "src/vr_backend.h",
    "chars": 887,
    "preview": "#ifndef _VR_BACKEND_H_\n#define _VR_BACKEND_H_\n\ntypedef struct vr_backend {\n\n    int id;\n    vr_eventloop vel;\n\n    /* So"
  },
  {
    "path": "src/vr_bitops.c",
    "chars": 39818,
    "preview": "#include <vr_core.h>\n\n/* -----------------------------------------------------------------------------\n * Helpers and lo"
  },
  {
    "path": "src/vr_bitops.h",
    "chars": 1238,
    "preview": "#ifndef _VR_BITOPS_H_\n#define _VR_BITOPS_H_\n\nsize_t redisPopcount(void *s, long count);\nlong redisBitpos(void *s, unsign"
  },
  {
    "path": "src/vr_block.c",
    "chars": 2205,
    "preview": "#include <vr_core.h>\n\n\n/* Unblock a client calling the right function depending on the kind\n * of operation the client i"
  },
  {
    "path": "src/vr_block.h",
    "chars": 1042,
    "preview": "#ifndef _VR_BLOCK_H_\n#define _VR_BLOCK_H_\n\n/* This structure holds the blocking operation state for a client.\n * The fie"
  },
  {
    "path": "src/vr_client.c",
    "chars": 69909,
    "preview": "#include <vr_core.h>\n\nint ncurr_cconn = 0;       /* current # client connections */\n\nstatic void setProtocolError(client"
  },
  {
    "path": "src/vr_client.h",
    "chars": 11748,
    "preview": "#ifndef _VR_CLIENT_H_\n#define _VR_CLIENT_H_\n\n#define NET_MAX_WRITES_PER_EVENT (1024*64)\n\n#define PROTO_MAX_QUERYBUF_LEN "
  },
  {
    "path": "src/vr_command.c",
    "chars": 35212,
    "preview": "#include <vr_core.h>\n\n/* Command table. sds string -> command struct pointer. */\ndictType commandTableDictType = {\n    d"
  },
  {
    "path": "src/vr_command.h",
    "chars": 4407,
    "preview": "#ifndef _VR_COMMAND_H_\n#define _VR_COMMAND_H_\n\n/* Command flags. Please check the command table defined in the redis.c f"
  },
  {
    "path": "src/vr_conf.c",
    "chars": 61427,
    "preview": "#include <fcntl.h>\n\n#include <vr_core.h>\n\ntypedef const char *(*configEnumGetStrFun)(int type);\n\n#define CONF_TOKEN_ORGA"
  },
  {
    "path": "src/vr_conf.h",
    "chars": 6687,
    "preview": "#ifndef _VR_CONF_H_\n#define _VR_CONF_H_\n\n/* Config server option name */\n#define CONFIG_SOPN_DATABASES    \"databases\"\n#d"
  },
  {
    "path": "src/vr_connection.c",
    "chars": 7293,
    "preview": "#include <sys/uio.h>\n\n#include <vr_core.h>\n\nstatic void conn_free(struct conn *conn);\n\nstatic struct conn *\n_conn_get(co"
  },
  {
    "path": "src/vr_connection.h",
    "chars": 1745,
    "preview": "#ifndef _VR_CONNECTION_H_\n#define _VR_CONNECTION_H_\n\ntypedef struct conn_base {\n    dlist *free_connq;           /* free"
  },
  {
    "path": "src/vr_core.c",
    "chars": 98,
    "preview": "#include <stdlib.h>\n#include <unistd.h>\n\n#include <vr_core.h>\n\nstatic uint32_t reserved_fds = 0;\n\n"
  },
  {
    "path": "src/vr_core.h",
    "chars": 2929,
    "preview": "#ifndef _VR_CORE_H_\n#define _VR_CORE_H_\n\n#ifdef HAVE_CONFIG_H\n# include <config.h>\n#endif\n\n#include <dspecialconfig.h>\n\n"
  },
  {
    "path": "src/vr_db.c",
    "chars": 51995,
    "preview": "#include <signal.h>\n#include <ctype.h>\n\n#include <vr_core.h>\n\n/* Db->dict, keys are sds strings, vals are Redis objects."
  },
  {
    "path": "src/vr_db.h",
    "chars": 4859,
    "preview": "#ifndef _VR_DB_H_\n#define _VR_DB_H_\n\n/* To improve the quality of the LRU approximation we take a set of keys\n * that ar"
  },
  {
    "path": "src/vr_dict.c",
    "chars": 34223,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdarg.h>\n#include <limits.h>\n#include <sys/time.h>"
  },
  {
    "path": "src/vr_dict.h",
    "chars": 5031,
    "preview": "#ifndef _VR_DICT_H_\n#define _VR_DICT_H_\n\n#include <stdint.h>\n\n#define DICT_OK 0\n#define DICT_ERR 1\n\n/* Unused arguments "
  },
  {
    "path": "src/vr_eventloop.c",
    "chars": 3856,
    "preview": "#include <vr_core.h>\n\nint\nvr_eventloop_init(vr_eventloop *vel, int filelimit)\n{    \n    rstatus_t status;\n    int maxcli"
  },
  {
    "path": "src/vr_eventloop.h",
    "chars": 2127,
    "preview": "#ifndef _VR_EVENTLOOP_H_\n#define _VR_EVENTLOOP_H_\n\ntypedef struct vr_eventloop {\n    vr_thread thread;\n\n    aeEventLoop "
  },
  {
    "path": "src/vr_hyperloglog.c",
    "chars": 57080,
    "preview": "#include <vr_core.h>\n\n#include <stdint.h>\n#include <math.h>\n\n/* The Redis HyperLogLog implementation is based on the fol"
  },
  {
    "path": "src/vr_hyperloglog.h",
    "chars": 947,
    "preview": "#ifndef _VR_HYPERLOGLOG_H_\n#define _VR_HYPERLOGLOG_H_\n\nuint64_t MurmurHash64A (const void * key, int len, unsigned int s"
  },
  {
    "path": "src/vr_intset.c",
    "chars": 8130,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <vr_core.h>\n\n/* Note that these encodings are order"
  },
  {
    "path": "src/vr_intset.h",
    "chars": 536,
    "preview": "#ifndef _VR_INTSET_H_\n#define _VR_INTSET_H_\n\n#include <stdint.h>\n\ntypedef struct intset {\n    uint32_t encoding;\n    uin"
  },
  {
    "path": "src/vr_listen.c",
    "chars": 6971,
    "preview": "#include <sys/stat.h>\n#include <sys/un.h>\n\n#include <vr_core.h>\n\nvr_listen *\nvr_listen_create(sds listen_str)\n{\n    rsta"
  },
  {
    "path": "src/vr_listen.h",
    "chars": 523,
    "preview": "#ifndef _VR_LISTEN_H_\n#define _VR_LISTEN_H_\n\ntypedef struct vr_listen {\n    sds name;               /* hostname:port */\n"
  },
  {
    "path": "src/vr_lzf.h",
    "chars": 2385,
    "preview": "#ifndef _VR_LZF_H_\n#define _VR_LZF_H_\n\n/***********************************************************************\n**\n**\tlz"
  },
  {
    "path": "src/vr_lzfP.h",
    "chars": 3806,
    "preview": "#ifndef _VR_LZFP_H_\n#define _VR_LZFP_H_\n\n#define STANDALONE 1 /* at the moment, this is ok. */\n\n#ifndef STANDALONE\n#incl"
  },
  {
    "path": "src/vr_lzf_c.c",
    "chars": 6983,
    "preview": "#include <vr_lzfP.h>\n\n#define HSIZE (1 << (HLOG))\n\n/*\n * don't play with this unless you benchmark!\n * the data format i"
  },
  {
    "path": "src/vr_lzf_d.c",
    "chars": 4059,
    "preview": "#include <vr_lzfP.h>\n\n#if AVOID_ERRNO\n# define SET_ERRNO(n)\n#else\n# include <errno.h>\n# define SET_ERRNO(n) errno = (n)\n"
  },
  {
    "path": "src/vr_master.c",
    "chars": 5544,
    "preview": "#include <vr_core.h>\n\nvr_master master;\n\nstatic int setup_master(void);\nstatic void *master_thread_run(void *args);\n\nint"
  },
  {
    "path": "src/vr_master.h",
    "chars": 450,
    "preview": "#ifndef _VR_MASTER_H_\n#define _VR_MASTER_H_\n\ntypedef struct vr_master {\n\n    vr_eventloop vel;\n    \n    struct darray li"
  },
  {
    "path": "src/vr_multi.c",
    "chars": 6462,
    "preview": "#include <vr_core.h>\n\n/* ===================== WATCH (CAS alike for MULTI/EXEC) ===================\n *\n * The implementa"
  },
  {
    "path": "src/vr_multi.h",
    "chars": 1030,
    "preview": "#ifndef _VR_MULTI_H_\n#define _VR_MULTI_H_\n\n/* Client MULTI/EXEC state */\ntypedef struct multiCmd {\n    robj **argv;\n    "
  },
  {
    "path": "src/vr_notify.c",
    "chars": 3815,
    "preview": "#include <vr_core.h>\n\n/* This file implements keyspace events notification via Pub/Sub ad\n * described at http://redis.i"
  },
  {
    "path": "src/vr_notify.h",
    "chars": 747,
    "preview": "#ifndef _VR_NOTIFY_H_\n#define _VR_NOTIFY_H_\n\n/* Keyspace changes notification classes. Every class is associated with a\n"
  },
  {
    "path": "src/vr_object.c",
    "chars": 22631,
    "preview": "#include <math.h>\n#include <ctype.h>\n\n#include <vr_core.h>\n\n#ifdef __CYGWIN__\n#define strtold(a,b) ((long double)strtod("
  },
  {
    "path": "src/vr_object.h",
    "chars": 3733,
    "preview": "#ifndef _VR_OBJECT_H_\n#define _VR_OBJECT_H_\n\n#define OBJ_SHARED_INTEGERS 10000\n#define OBJ_SHARED_BULKHDR_LEN 32\n\n/* Obj"
  },
  {
    "path": "src/vr_pubsub.c",
    "chars": 8978,
    "preview": "#include <vr_core.h>\n\n/* Unsubscribe a client from a channel. Returns 1 if the operation succeeded, or\n * 0 if the clien"
  },
  {
    "path": "src/vr_pubsub.h",
    "chars": 738,
    "preview": "#ifndef _VR_PUBSUB_H_\n#define _VR_PUBSUB_H_\n\ntypedef struct pubsubPattern {\n    client *client;\n    robj *pattern;\n} pub"
  },
  {
    "path": "src/vr_quicklist.c",
    "chars": 48937,
    "preview": "#include <string.h> /* for memcpy */\n\n#include <vr_core.h>\n\n#if defined(REDIS_TEST) || defined(REDIS_TEST_VERBOSE)\n#incl"
  },
  {
    "path": "src/vr_quicklist.h",
    "chars": 6074,
    "preview": "#ifndef _VR_QUICKLIST_H_\n#define _VR_QUICKLIST_H_\n\n/* Node, quicklist, and Iterator are the only data structures used cu"
  },
  {
    "path": "src/vr_rbtree.c",
    "chars": 7904,
    "preview": "#include <vr_core.h>\n\nvoid\nrbtree_node_init(struct rbnode *node)\n{\n    node->left = NULL;\n    node->right = NULL;\n    no"
  },
  {
    "path": "src/vr_rbtree.h",
    "chars": 1032,
    "preview": "#ifndef _VR_RBTREE_\n#define _VR_RBTREE_\n\n#define rbtree_red(_node)           ((_node)->color = 1)\n#define rbtree_black(_"
  },
  {
    "path": "src/vr_rdb.c",
    "chars": 297,
    "preview": "#include <vr_core.h>\n\n/* Save the DB on disk. Return C_ERR on error, C_OK on success. */\nint rdbSave(char *filename) {\n "
  },
  {
    "path": "src/vr_rdb.h",
    "chars": 1440,
    "preview": "#ifndef _VR_RDB_H_\n#define _VR_RDB_H_\n\n/* Defines related to the dump file format. To store 32 bits lengths for short\n *"
  },
  {
    "path": "src/vr_replication.c",
    "chars": 16365,
    "preview": "#include <vr_core.h>\n\nstruct vr_replication repl;\n\nint vr_replication_init(void)\n{\n    vr_eventloop_init(&repl.vel,1000)"
  },
  {
    "path": "src/vr_replication.h",
    "chars": 6037,
    "preview": "#ifndef _VR_REPLICATION_H_\n#define _VR_REPLICATION_H_\n\n/* Slave replication state. Used in server.repl_state for slaves "
  },
  {
    "path": "src/vr_scripting.c",
    "chars": 85,
    "preview": "#include <vr_core.h>\n\nvoid scriptCommand(client *c) {\n    addReply(c,shared.ok);\n}\n\n\n"
  },
  {
    "path": "src/vr_scripting.h",
    "chars": 90,
    "preview": "#ifndef _VR_SCRIPTING_H_\n#define _VR_SCRIPTING_H_\n\nvoid scriptCommand(client *c);\n\n#endif\n"
  },
  {
    "path": "src/vr_server.c",
    "chars": 42907,
    "preview": "#include <sys/utsname.h>\n\n#include <vr_core.h>\n\n/* Global vars */\nstruct vr_server server; /* server global state */\n\n/*"
  },
  {
    "path": "src/vr_server.h",
    "chars": 15141,
    "preview": "#ifndef _VR_SERVER_H_\n#define _VR_SERVER_H_\n\n#define CONFIG_MIN_RESERVED_FDS 32 /* For extra operations of\n             "
  },
  {
    "path": "src/vr_signal.c",
    "chars": 2417,
    "preview": "#include <stdlib.h>\n#include <signal.h>\n\n#include <vr_core.h>\n#include <vr_signal.h>\n\nstatic struct signal signals[] = {"
  },
  {
    "path": "src/vr_signal.h",
    "chars": 243,
    "preview": "#ifndef _VR_SIGNAL_H_\n#define _VR_SIGNAL_H_\n\nstruct signal {\n    int  signo;\n    char *signame;\n    int  flags;\n    void"
  },
  {
    "path": "src/vr_slowlog.c",
    "chars": 5359,
    "preview": "#include <vr_core.h>\n\nstatic pthread_rwlock_t rwlocker;\nstatic dlist *slowlog;                  /* SLOWLOG list of comma"
  },
  {
    "path": "src/vr_slowlog.h",
    "chars": 660,
    "preview": "#ifndef _VR_SLOWLOG_H_\n#define _VR_SLOWLOG_H_\n\n#define SLOWLOG_ENTRY_MAX_ARGC 32\n#define SLOWLOG_ENTRY_MAX_STRING 128\n\n/"
  },
  {
    "path": "src/vr_stats.c",
    "chars": 2536,
    "preview": "#include <vr_core.h>\n\nint\nvr_stats_init(vr_stats *stats)\n{\n    rstatus_t ret;\n\n    if (stats == NULL) {\n        return V"
  },
  {
    "path": "src/vr_stats.h",
    "chars": 4295,
    "preview": "#ifndef _VR_STATS_H_\n#define _VR_STATS_H_\n\n#if 1\n#define STATS_ATOMIC_FIRST 1\n#endif\n\n/* Instantaneous metrics tracking."
  },
  {
    "path": "src/vr_t_hash.c",
    "chars": 27379,
    "preview": "#include <math.h>\n\n#include <vr_core.h>\n\n/*-----------------------------------------------------------------------------"
  },
  {
    "path": "src/vr_t_hash.h",
    "chars": 1721,
    "preview": "#ifndef _VR_T_HASH_H_\n#define _VR_T_HASH_H_\n\nvoid hashTypeTryConversion(robj *o, robj **argv, int start, int end);\nvoid "
  },
  {
    "path": "src/vr_t_list.c",
    "chars": 35568,
    "preview": "#include <vr_core.h>\n\n/*-----------------------------------------------------------------------------\n * List API\n *----"
  },
  {
    "path": "src/vr_t_list.h",
    "chars": 1882,
    "preview": "#ifndef _VR_T_LIST_H_\n#define _VR_T_LIST_H_\n\nvoid listTypePush(robj *subject, robj *value, int where);\nvoid *listPopSave"
  },
  {
    "path": "src/vr_t_set.c",
    "chars": 45407,
    "preview": "#include <vr_core.h>\n\n/*-----------------------------------------------------------------------------\n * Set Commands\n *"
  },
  {
    "path": "src/vr_t_set.h",
    "chars": 1481,
    "preview": "#ifndef _VR_T_SET_H_\n#define _VR_T_SET_H_\n\nrobj *setTypeCreate(robj *value);\nint setTypeAdd(robj *subject, robj *value);"
  },
  {
    "path": "src/vr_t_string.c",
    "chars": 18060,
    "preview": "#include <vr_core.h>\n\n/*-----------------------------------------------------------------------------\n * String Commands"
  },
  {
    "path": "src/vr_t_string.h",
    "chars": 862,
    "preview": "#ifndef _VR_T_STRING_H_\n#define _VR_T_STRING_H_\n\nvoid setGenericCommand(client *c, int flags, robj *key, robj *val, robj"
  },
  {
    "path": "src/vr_t_zset.c",
    "chars": 96010,
    "preview": "#include <vr_core.h>\n\nstatic int zslLexValueGteMin(robj *value, zlexrangespec *spec);\nstatic int zslLexValueLteMax(robj "
  },
  {
    "path": "src/vr_t_zset.h",
    "chars": 6422,
    "preview": "#ifndef _VR_T_ZSET_H_\n#define _VR_T_ZSET_H_\n\n/* Struct to hold a inclusive/exclusive range spec by score comparison. */\n"
  },
  {
    "path": "src/vr_thread.c",
    "chars": 887,
    "preview": "#include <vr_core.h>\n\nint\nvr_thread_init(vr_thread *thread)\n{    \n    if (thread == NULL) {\n        return VR_ERROR;\n   "
  },
  {
    "path": "src/vr_thread.h",
    "chars": 346,
    "preview": "#ifndef _VR_THREAD_H_\n#define _VR_THREAD_H_\n\ntypedef void *(*vr_thread_func_t)(void *data);\n\ntypedef struct vr_thread {\n"
  },
  {
    "path": "src/vr_util.c",
    "chars": 29532,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n#include <string.h>\n#include <unistd.h>\n#include <fcntl.h>\n#i"
  },
  {
    "path": "src/vr_util.h",
    "chars": 6194,
    "preview": "#ifndef _VR_UTIL_H_\n#define _VR_UTIL_H_\n\n#include <stdarg.h>\n#include <stdint.h>\n#include <stdbool.h>\n\n#include <netinet"
  },
  {
    "path": "src/vr_worker.c",
    "chars": 12662,
    "preview": "#include <vr_core.h>\n\n/* Which thread we assigned a connection to most recently. */\nstatic int last_worker_thread = -1;\n"
  },
  {
    "path": "src/vr_worker.h",
    "chars": 1607,
    "preview": "#ifndef _VR_WORKER_H_\n#define _VR_WORKER_H_\n\ntypedef struct vr_worker {\n\n    int id;\n    vr_eventloop vel;\n    \n    int "
  },
  {
    "path": "src/vr_ziplist.c",
    "chars": 61396,
    "preview": "/* The ziplist is a specially encoded dually linked list that is designed\n * to be very memory efficient. It stores both"
  },
  {
    "path": "src/vr_ziplist.h",
    "chars": 1203,
    "preview": "#ifndef _ZIPLIST_H\n#define _ZIPLIST_H\n\n#define ZIPLIST_HEAD 0\n#define ZIPLIST_TAIL 1\n\nunsigned char *ziplistNew(void);\nu"
  },
  {
    "path": "src/vr_zipmap.c",
    "chars": 13846,
    "preview": "/* String -> String Map data structure optimized for size.\n * This file implements a data structure mapping strings to o"
  },
  {
    "path": "src/vr_zipmap.h",
    "chars": 800,
    "preview": "#ifndef _ZIPMAP_H\n#define _ZIPMAP_H\n\nunsigned char *zipmapNew(void);\nunsigned char *zipmapSet(unsigned char *zm, unsigne"
  },
  {
    "path": "tests/.gitignore",
    "chars": 17,
    "preview": "*.pyc\n*.out\n*.log"
  },
  {
    "path": "tests/Makefile.am",
    "chars": 3210,
    "preview": "MAINTAINERCLEANFILES = Makefile.in\n\nAM_CPPFLAGS =\nif !OS_SOLARIS\nAM_CPPFLAGS += -D_GNU_SOURCE\nendif\nAM_CPPFLAGS += -I $("
  },
  {
    "path": "tests/vrabtest.c",
    "chars": 23071,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <getopt.h>\n#include <fcntl.h>\n#include <errno.h>\n#include <signal.h>\n#in"
  },
  {
    "path": "tests/vrabtest.h",
    "chars": 988,
    "preview": "#ifndef _VRABTEST_H_\n#define _VRABTEST_H_\n\n#include <darray.h>\n\nstruct redisContext;\nstruct redisAsyncContext;\nstruct ab"
  },
  {
    "path": "tests/vrt_backend.c",
    "chars": 11479,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <getopt.h>\n#include <fcntl.h>\n#include <errno.h>\n#in"
  },
  {
    "path": "tests/vrt_backend.h",
    "chars": 694,
    "preview": "#ifndef _VRT_BACKEND_H_\n#define _VRT_BACKEND_H_\n\n#include <darray.h>\n\nstruct abtest_group;\nstruct dlist;\nstruct dmtlist;"
  },
  {
    "path": "tests/vrt_benchmark.c",
    "chars": 52271,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <getopt.h>\n#include <fcntl.h>\n#include <errno.h>\n#in"
  },
  {
    "path": "tests/vrt_check_data.c",
    "chars": 32742,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <getopt.h>\n#include <fcntl.h>\n#include <errno.h>\n#in"
  },
  {
    "path": "tests/vrt_check_data.h",
    "chars": 589,
    "preview": "#ifndef _VRT_CHECK_DATA_H_\n#define _VRT_CHECK_DATA_H_\n\nint vrt_data_checker_init(char *checker, char *test_target_groups"
  },
  {
    "path": "tests/vrt_dispatch_data.c",
    "chars": 16818,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <getopt.h>\n#include <fcntl.h>\n#include <errno.h>\n#in"
  },
  {
    "path": "tests/vrt_dispatch_data.h",
    "chars": 1404,
    "preview": "#ifndef _VRT_DISPATCH_DATA_H_\n#define _VRT_DISPATCH_DATA_H_\n\n#include <darray.h>\n\nstruct abtest_group;\nstruct dlist;\nstr"
  },
  {
    "path": "tests/vrt_produce_data.c",
    "chars": 61002,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <getopt.h>\n#include <fcntl.h>\n#include <errno.h>\n#in"
  },
  {
    "path": "tests/vrt_produce_data.h",
    "chars": 5040,
    "preview": "#ifndef _VRT_PRODUCE_DATA_H_\n#define _VRT_PRODUCE_DATA_H_\n\n/* Producer flags. Please check the producer table defined in"
  },
  {
    "path": "tests/vrt_public.c",
    "chars": 16836,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <getopt.h>\n#include <fcntl.h>\n#include <errno.h>\n#include <signal.h>\n#in"
  },
  {
    "path": "tests/vrt_public.h",
    "chars": 4243,
    "preview": "#ifndef _VRT_PUBLIC_H_\n#define _VRT_PUBLIC_H_\n\n#ifdef HAVE_CONFIG_H\n# include <config.h>\n#endif\n\n#include <dspecialconfi"
  },
  {
    "path": "tests/vrt_simple.c",
    "chars": 40128,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <getopt.h>\n#include <fcntl.h>\n#include <errno.h>\n#in"
  },
  {
    "path": "tests/vrt_simple.h",
    "chars": 79,
    "preview": "#ifndef _VRT_SIMPLE_H_\n#define _VRT_SIMPLE_H_\n\nint simple_test(void);\n\n\n#endif\n"
  },
  {
    "path": "tests/vrt_util.c",
    "chars": 16289,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdint.h>\n#include <errno.h>\n#include <fcntl.h>\n#include <unistd.h>\n#in"
  },
  {
    "path": "tests/vrt_util.h",
    "chars": 2292,
    "preview": "#ifndef _VRT_UTIL_H_\n#define _VRT_UTIL_H_\n\n#ifdef HAVE_CONFIG_H\n# include <config.h>\n#endif\n\n#ifdef HAVE_DEBUG_LOG\n# def"
  },
  {
    "path": "tests/vrtest.c",
    "chars": 3151,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <getopt.h>\n#include <fcntl.h>\n#include <errno.h>\n#include <signal.h>\n#in"
  },
  {
    "path": "tools/.gitignore",
    "chars": 18,
    "preview": "*.pyc\n*.out\n*.log\n"
  }
]

// ... and 1 more files (download for full content)

About this extraction

This page contains the full source code of the vipshop/vire GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 174 files (1.6 MB), approximately 462.4k tokens, and a symbol index with 1779 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!