fix a bug in update_continuum
authorYin Chen <subdragon@gmail.com>
Wed, 20 Aug 2008 09:05:16 +0000 (17:05 +0800)
committerYin Chen <subdragon@gmail.com>
Wed, 20 Aug 2008 09:05:16 +0000 (17:05 +0800)
It will casue the valgrind to report "Conditional jump or move depends on uninitialised value(s)"

libmemcached/memcached_hosts.c

index 54440d3582607cd6115245fd906bfc9ba7af7eff..eb8f45e5f37b61a9b8c6dee2ca2116f363d569d6 100644 (file)
@@ -174,9 +174,9 @@ memcached_return update_continuum(memcached_st *ptr)
   WATCHPOINT_ASSERT(ptr->continuum);
   WATCHPOINT_ASSERT(ptr->number_of_hosts);
   WATCHPOINT_ASSERT(ptr->number_of_hosts * MEMCACHED_POINTS_PER_SERVER <= MEMCACHED_CONTINUUM_SIZE);
-  qsort(ptr->continuum, ptr->number_of_hosts * MEMCACHED_POINTS_PER_SERVER, sizeof(memcached_continuum_item_st), continuum_item_cmp);
-
   ptr->continuum_points_counter= pointer_counter;
+  qsort(ptr->continuum, ptr->continuum_points_counter, sizeof(memcached_continuum_item_st), continuum_item_cmp);
+
   if (stat_p)
     memcached_stat_free(NULL, stat_p);