<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,11 @@
 Ideally, you want to make a static binary, otherwise the dynamic
 linker pollutes your address space with shared libs right in the
-middle.
+middle.  (NOTE: actually, this shouldn't matter so much anymore, now
+that we only allocate huge, fixed-size slabs)
 
 Make sure your libevent has epoll (Linux) or kqueue (BSD) support.
 Using poll or select only is slow, and works for testing, but
-shouldn't be used for high-traffice memcache installations.
+shouldn't be used for high-traffic memcache installations.
 
 To build libevent with epoll on Linux, you need:
 </diff>
      <filename>BUILD</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,5 @@
 Dependencies:
 
-   -- Judy, http://judy.sf.net/ (Debian package libjudy-dev)
    -- libevent, http://www.monkey.org/~provos/libevent/ (libevent-dev)
 
 If using Linux, you need a kernel with epoll.  Sure, libevent will</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -151,8 +151,8 @@ item *assoc_find(char *key) {
     return 0;
 }
 
-/* returns the address of a item* before the key.  if *item == 0,
-   the item wasn't found, and a new node should be allocated */
+/* returns the address of the item pointer before the key.  if *item == 0,
+   the item wasn't found */
 
 static item** _hashitem_before (char *key) {
     ub4 hv = hash(key, strlen(key), 0) &amp; hashmask(HASHPOWER);
@@ -164,12 +164,11 @@ static item** _hashitem_before (char *key) {
     return pos;
 }
 
+/* Note: this isn't an assoc_update.  The key must not already exist to call this */
 int assoc_insert(char *key, item *it) {
-    item **before = _hashitem_before(key);
-    /* Note: in practice, *before is always 0, as the callers always unlink the old
-       item before replacing it with a new item of the same key.  TODO: assert? */
-    it-&gt;h_next = *before ? (*before)-&gt;h_next : 0;
-    *before = it;
+    ub4 hv = hash(key, strlen(key), 0) &amp; hashmask(HASHPOWER);
+    it-&gt;h_next = hashtable[hv];
+    hashtable[hv] = it;
     return 1;
 }
 
@@ -181,7 +180,7 @@ void assoc_delete(char *key) {
         *before = nxt;
         return;
     }
-    /* Note:  we actually get here.  the callers don't delete things 
+    /* Note:  we never actually get here.  the callers don't delete things 
        they can't find.  TODO: assert?  */
 }
 </diff>
      <filename>assoc.c</filename>
    </modified>
    <modified>
      <diff>@@ -129,7 +129,7 @@ void item_unlink_q(item *it) {
 int item_link(item *it) {
     it-&gt;it_flags |= ITEM_LINKED;
     it-&gt;time = time(0);
-    assoc_insert(ITEM_key(it), (void *)it);
+    assoc_insert(ITEM_key(it), it);
 
     stats.curr_bytes += ITEM_ntotal(it);
     stats.curr_items += 1;</diff>
      <filename>items.c</filename>
    </modified>
    <modified>
      <diff>@@ -219,7 +219,7 @@ void complete_nread(conn *c) {
             break;
         }
 
-        old_it = (item *)assoc_find(ITEM_key(it));
+        old_it = assoc_find(ITEM_key(it));
 
         if (old_it &amp;&amp; old_it-&gt;exptime &amp;&amp; old_it-&gt;exptime &lt; now) {
             item_unlink(old_it);
@@ -420,13 +420,13 @@ void process_command(conn *c, char *command) {
         (strncmp(command, &quot;set &quot;, 4) == 0 &amp;&amp; (comm = NREAD_SET)) ||
         (strncmp(command, &quot;replace &quot;, 8) == 0 &amp;&amp; (comm = NREAD_REPLACE))) {
 
-        char key[256];
+        char key[251];
         int flags;
         time_t expire;
         int len, res;
         item *it;
 
-        res = sscanf(command, &quot;%*s %255s %u %lu %d\n&quot;, key, &amp;flags, &amp;expire, &amp;len);
+        res = sscanf(command, &quot;%*s %250s %u %lu %d\n&quot;, key, &amp;flags, &amp;expire, &amp;len);
         if (res!=4 || strlen(key)==0 ) {
             out_string(c, &quot;CLIENT_ERROR bad command line format&quot;);
             return;
@@ -454,12 +454,12 @@ void process_command(conn *c, char *command) {
         unsigned int value;
         item *it;
         unsigned int delta;
-        char key[255];
+        char key[251];
         int res;
         char *ptr;
         time_t now = time(0);
 
-        res = sscanf(command, &quot;%*s %255s %u\n&quot;, key, &amp;delta);
+        res = sscanf(command, &quot;%*s %250s %u\n&quot;, key, &amp;delta);
         if (res!=2 || strlen(key)==0 ) {
             out_string(c, &quot;CLIENT_ERROR bad command line format&quot;);
             return;
@@ -514,16 +514,16 @@ void process_command(conn *c, char *command) {
     if (strncmp(command, &quot;get &quot;, 4) == 0) {
 
         char *start = command + 4;
-        char key[256];
+        char key[251];
         int next;
         int i = 0;
         item *it;
         time_t now = time(0);
 
-        while(sscanf(start, &quot; %255s%n&quot;, key, &amp;next) &gt;= 1) {
+        while(sscanf(start, &quot; %250s%n&quot;, key, &amp;next) &gt;= 1) {
             start+=next;
             stats.get_cmds++;
-            it = (item *)assoc_find(key);
+            it = assoc_find(key);
             if (it &amp;&amp; (it-&gt;it_flags &amp; ITEM_DELETED)) {
                 it = 0;
             }
@@ -558,11 +558,11 @@ void process_command(conn *c, char *command) {
     }
 
     if (strncmp(command, &quot;delete &quot;, 7) == 0) {
-        char key[256];
+        char key[251];
         char *start = command+7;
         item *it;
 
-        sscanf(start, &quot; %255s&quot;, key);
+        sscanf(start, &quot; %250s&quot;, key);
         it = assoc_find(key);
         if (!it) {
             out_string(c, &quot;NOT_FOUND&quot;);
@@ -862,10 +862,10 @@ void drive_machine(conn *c) {
         case conn_mwrite:
             /* 
              * we're writing ibytes bytes from iptr. iptr alternates between
-             * ibuf, where we build a string &quot;VALUE...&quot;, and it-&gt;data for the 
+             * ibuf, where we build a string &quot;VALUE...&quot;, and ITEM_data(it) for the 
              * current item. When we finish a chunk, we choose the next one using 
              * ipart, which has the following semantics: 0 - start the loop, 1 - 
-             * we finished ibuf, go to current it-&gt;data; 2 - we finished it-&gt;data,
+             * we finished ibuf, go to current ITEM_data(it); 2 - we finished ITEM_data(it),
              * move to the next item and build its ibuf; 3 - we finished all items, 
              * write &quot;END&quot;.
              */</diff>
      <filename>memcached.c</filename>
    </modified>
    <modified>
      <diff>@@ -52,7 +52,7 @@ typedef struct _stritem {
 #define ITEM_key(item) ((char*)&amp;((item)-&gt;end[0]))
 
 /* warning: don't use these macros with a function, as it evals its arg twice */
-#define ITEM_data(item) ((void*) &amp;((item)-&gt;end[0]) + (item)-&gt;nkey)
+#define ITEM_data(item) ((char*) &amp;((item)-&gt;end[0]) + (item)-&gt;nkey)
 #define ITEM_ntotal(item) (sizeof(struct _stritem) + (item)-&gt;nkey + (item)-&gt;nbytes)
 
 enum conn_states {
@@ -95,7 +95,7 @@ typedef struct {
     /* 
      * item is used to hold an item structure created after reading the command
      * line of set/add/replace commands, but before we finished reading the actual 
-     * data. The data is read into item-&gt;data to avoid extra copying.
+     * data. The data is read into ITEM_data(item) to avoid extra copying.
      */
 
     void   *item;     /* for commands set/add/replace  */</diff>
      <filename>memcached.h</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f6d334e03c17de77f137e3176245f71e2f356ae0</id>
    </parent>
  </parents>
  <author>
    <name>Brad Fitzpatrick</name>
    <email>brad@danga.com</email>
  </author>
  <url>http://github.com/dustin/memcached/commit/7917af40da246fa99ca27734b31af2ae2ac1b54a</url>
  <id>7917af40da246fa99ca27734b31af2ae2ac1b54a</id>
  <committed-date>2003-06-21T19:52:05-07:00</committed-date>
  <authored-date>2003-06-21T19:52:05-07:00</authored-date>
  <message>misc fixes as suggested by avva.  lot of comment updates, mostly.


git-svn-id: http://code.sixapart.com/svn/memcached/trunk@35 b0b603af-a30f-0410-a34e-baf09ae79d0b</message>
  <tree>7c5e0da643ba2802f73530c6450e308eb80e0887</tree>
  <committer>
    <name>Brad Fitzpatrick</name>
    <email>brad@danga.com</email>
  </committer>
</commit>
