public
Description: This is where my memcached work lives before svn munges the changes.
Homepage: http://www.danga.com/memcached/
Clone URL: git://github.com/dustin/memcached.git
Search Repo:
gcc -pedantic changes, comments, signed/unsigned changes. also convert 
expanded to bool

git-svn-id: http://code.sixapart.com/svn/memcached/trunk/server@591 
b0b603af-a30f-0410-a34e-baf09ae79d0b
plindner (author)
Mon Jul 09 07:28:54 -0700 2007
commit  2a6f88ed0ea7a2161ccd1567165213c99adc1cd8
tree    d3af8e6c40a7c9157495e45e0ddb5c80eff624b5
parent  8685aaf0df48527a6a8f968d50aac66ca2193eca
...
153
154
155
156
 
157
158
159
...
331
332
333
334
 
335
336
337
...
449
450
451
452
 
453
454
455
...
464
465
466
467
 
468
469
470
 
471
472
473
474
475
476
 
477
478
479
...
488
489
490
491
 
492
493
494
...
514
515
516
517
 
518
519
520
...
539
540
541
542
 
543
544
545
...
566
567
568
569
 
570
571
572
...
577
578
579
580
 
581
582
583
...
153
154
155
 
156
157
158
159
...
331
332
333
 
334
335
336
337
...
449
450
451
 
452
453
454
455
...
464
465
466
 
467
468
469
 
470
471
472
473
474
475
 
476
477
478
479
...
488
489
490
 
491
492
493
494
...
514
515
516
 
517
518
519
520
...
539
540
541
 
542
543
544
545
...
566
567
568
 
569
570
571
572
...
577
578
579
 
580
581
582
583
0
@@ -153,7 +153,7 @@ uint32_t hash(
0
     const uint32_t *k = key; /* read 32-bit chunks */
0
 #ifdef VALGRIND
0
     const uint8_t *k8;
0
-#endif // ifdef VALGRIND
0
+#endif /* ifdef VALGRIND */
0
 
0
     /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
0
     while (length > 12)
0
@@ -331,7 +331,7 @@ uint32_t hash( const void *key, size_t length, const uint32_t initval)
0
     const uint32_t *k = key; /* read 32-bit chunks */
0
 #ifdef VALGRIND
0
     const uint8_t *k8;
0
-#endif // ifdef VALGRIND
0
+#endif /* ifdef VALGRIND */
0
 
0
     /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
0
     while (length > 12)
0
@@ -449,7 +449,7 @@ typedef unsigned long int ub4; /* unsigned 4-byte quantities */
0
 typedef unsigned char ub1; /* unsigned 1-byte quantities */
0
 
0
 /* how many powers of 2's worth of buckets we use */
0
-static int hashpower = 16;
0
+static unsigned int hashpower = 16;
0
 
0
 #define hashsize(n) ((ub4)1<<(n))
0
 #define hashmask(n) (hashsize(n)-1)
0
@@ -464,16 +464,16 @@ static item** primary_hashtable = 0;
0
 static item** old_hashtable = 0;
0
 
0
 /* Number of items in the hash table. */
0
-static int hash_items = 0;
0
+static unsigned int hash_items = 0;
0
 
0
 /* Flag: Are we in the middle of expanding now? */
0
-static int expanding = 0;
0
+static bool expanding = false;
0
 
0
 /*
0
  * During expansion we migrate values with bucket granularity; this is how
0
  * far we've gotten so far. Ranges from 0 .. hashsize(hashpower - 1) - 1.
0
  */
0
-static int expand_bucket = 0;
0
+static unsigned int expand_bucket = 0;
0
 
0
 void assoc_init(void) {
0
     unsigned int hash_size = hashsize(hashpower) * sizeof(void*);
0
@@ -488,7 +488,7 @@ void assoc_init(void) {
0
 item *assoc_find(const char *key, const size_t nkey) {
0
     uint32_t hv = hash(key, nkey, 0);
0
     item *it;
0
- int oldbucket;
0
+ unsigned int oldbucket;
0
 
0
     if (expanding &&
0
         (oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket)
0
@@ -514,7 +514,7 @@ item *assoc_find(const char *key, const size_t nkey) {
0
 static item** _hashitem_before (const char *key, const size_t nkey) {
0
     uint32_t hv = hash(key, nkey, 0);
0
     item **pos;
0
- int oldbucket;
0
+ unsigned int oldbucket;
0
 
0
     if (expanding &&
0
         (oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket)
0
@@ -539,7 +539,7 @@ static void assoc_expand(void) {
0
         if (settings.verbose > 1)
0
             fprintf(stderr, "Hash table expansion starting\n");
0
         hashpower++;
0
- expanding = 1;
0
+ expanding = true;
0
         expand_bucket = 0;
0
         do_assoc_move_next_bucket();
0
     } else {
0
@@ -566,7 +566,7 @@ void do_assoc_move_next_bucket(void) {
0
 
0
         expand_bucket++;
0
         if (expand_bucket == hashsize(hashpower - 1)) {
0
- expanding = 0;
0
+ expanding = false;
0
             free(old_hashtable);
0
             if (settings.verbose > 1)
0
                 fprintf(stderr, "Hash table expansion done\n");
0
@@ -577,7 +577,7 @@ void do_assoc_move_next_bucket(void) {
0
 /* Note: this isn't an assoc_update. The key must not already exist to call this */
0
 int assoc_insert(item *it) {
0
     uint32_t hv;
0
- int oldbucket;
0
+ unsigned int oldbucket;
0
 
0
     assert(assoc_find(ITEM_key(it), it->nkey) == 0); /* shouldn't have duplicately named things defined */
0
 
...
51
52
53
54
 
55
56
57
...
150
151
152
153
 
154
155
156
...
267
268
269
270
 
271
272
273
274
275
 
 
276
277
278
...
332
333
334
335
 
336
337
338
...
371
372
373
374
375
 
 
376
377
378
379
380
381
 
382
383
384
...
393
394
395
396
 
397
398
399
400
 
401
402
403
...
412
413
414
415
 
416
417
418
...
51
52
53
 
54
55
56
57
...
150
151
152
 
153
154
155
156
...
267
268
269
 
270
271
272
273
 
 
274
275
276
277
278
...
332
333
334
 
335
336
337
338
...
371
372
373
 
 
374
375
376
377
378
379
380
 
381
382
383
384
...
393
394
395
 
396
397
398
399
 
400
401
402
403
...
412
413
414
 
415
416
417
418
0
@@ -51,7 +51,7 @@ void item_init(void) {
0
 # define DEBUG_REFCNT(it,op) while(0)
0
 #endif
0
 
0
-/*
0
+/**
0
  * Generates the variable-sized part of the header for an object.
0
  *
0
  * key - The key
0
@@ -150,7 +150,7 @@ void item_free(item *it) {
0
     slabs_free(it, ntotal);
0
 }
0
 
0
-/*
0
+/**
0
  * Returns true if an item will fit in the cache (its size does not exceed
0
  * the maximum for a cache entry.)
0
  */
0
@@ -267,12 +267,12 @@ int do_item_replace(item *it, item *new_it) {
0
 
0
 /*@null@*/
0
 char *do_item_cachedump(const unsigned int slabs_clsid, const unsigned int limit, unsigned int *bytes) {
0
- int memlimit = 2 * 1024 * 1024; /* 2MB max response size */
0
+ unsigned int memlimit = 2 * 1024 * 1024; /* 2MB max response size */
0
     char *buffer;
0
     unsigned int bufcurr;
0
     item *it;
0
- int len;
0
- int shown = 0;
0
+ unsigned int len;
0
+ unsigned int shown = 0;
0
     char temp[512];
0
 
0
     if (slabs_clsid > LARGEST_ID) return NULL;
0
@@ -332,7 +332,7 @@ char *do_item_stats(int *bytes) {
0
     return buffer;
0
 }
0
 
0
-/* dumps out a list of objects of each size, with granularity of 32 bytes */
0
+/** dumps out a list of objects of each size, with granularity of 32 bytes */
0
 /*@null@*/
0
 char* do_item_stats_sizes(int *bytes) {
0
     const int num_buckets = 32768; /* max 1MB object, divided into 32 bytes size buckets */
0
@@ -371,14 +371,14 @@ char* do_item_stats_sizes(int *bytes) {
0
     return buf;
0
 }
0
 
0
-/* returns true if a deleted item's delete-locked-time is over, and it
0
- should be removed from the namespace */
0
+/** returns true if a deleted item's delete-locked-time is over, and it
0
+ should be removed from the namespace */
0
 bool item_delete_lock_over (item *it) {
0
     assert(it->it_flags & ITEM_DELETED);
0
     return (current_time >= it->exptime);
0
 }
0
 
0
-/* wrapper around assoc_find which does the lazy expiration/deletion logic */
0
+/** wrapper around assoc_find which does the lazy expiration/deletion logic */
0
 item *do_item_get_notedeleted(const char *key, const size_t nkey, bool *delete_locked) {
0
     item *it = assoc_find(key, nkey);
0
     if (delete_locked) *delete_locked = false;
0
@@ -393,11 +393,11 @@ item *do_item_get_notedeleted(const char *key, const size_t nkey, bool *delete_l
0
     }
0
     if (it != NULL && settings.oldest_live != 0 && settings.oldest_live <= current_time &&
0
         it->time <= settings.oldest_live) {
0
- do_item_unlink(it); // MTSAFE - cache_lock held
0
+ do_item_unlink(it); /* MTSAFE - cache_lock held */
0
         it = 0;
0
     }
0
     if (it != NULL && it->exptime != 0 && it->exptime <= current_time) {
0
- do_item_unlink(it); // MTSAFE - cache_lock held
0
+ do_item_unlink(it); /* MTSAFE - cache_lock held */
0
         it = 0;
0
     }
0
 
0
@@ -412,7 +412,7 @@ item *item_get(const char *key, const size_t nkey) {
0
     return item_get_notedeleted(key, nkey, 0);
0
 }
0
 
0
-/* returns an item whether or not it's delete-locked or expired. */
0
+/** returns an item whether or not it's delete-locked or expired. */
0
 item *do_item_get_nocheck(const char *key, const size_t nkey) {
0
     item *it = assoc_find(key, nkey);
0
     if (it) {
...
88
89
90
91
 
92
93
94
...
88
89
90
 
91
92
93
94
0
@@ -88,7 +88,7 @@ unsigned int slabs_clsid(const size_t size) {
0
     return res;
0
 }
0
 
0
-/*
0
+/**
0
  * Determines the chunk sizes and initializes the slab class descriptors
0
  * accordingly.
0
  */
...
98
99
100
101
 
102
103
104
...
98
99
100
 
101
102
103
104
0
@@ -98,7 +98,7 @@ static PREFIX_STATS *stats_prefix_find(const char *key) {
0
     }
0
 
0
     strncpy(pfs->prefix, key, length);
0
- pfs->prefix[length] = '\0'; // because strncpy() sucks
0
+ pfs->prefix[length] = '\0'; /* because strncpy() sucks */
0
     pfs->prefix_len = length;
0
 
0
     pfs->next = prefix_stats[hashval];
...
632
633
634
635
 
636
637
638
...
632
633
634
 
635
636
637
638
0
@@ -632,7 +632,7 @@ void thread_init(int nthreads, struct event_base *main_base) {
0
 
0
     /* Wait for all the threads to set themselves up before returning. */
0
     pthread_mutex_lock(&init_lock);
0
- init_count++; // main thread
0
+ init_count++; /* main thread */
0
     while (init_count < nthreads) {
0
         pthread_cond_wait(&init_cond, &init_lock);
0
     }

Comments

    No one has commented yet.