[memcached] bradfitz, r391: 64bit fixes

commits at code.sixapart.com commits at code.sixapart.com
Sat Sep 9 20:36:58 UTC 2006


64bit fixes

U   branches/memcached-1.1.x/memcached.h
U   branches/memcached-1.1.x/slabs.c


Modified: branches/memcached-1.1.x/memcached.h
===================================================================
--- branches/memcached-1.1.x/memcached.h	2006-09-09 20:25:35 UTC (rev 390)
+++ branches/memcached-1.1.x/memcached.h	2006-09-09 20:36:57 UTC (rev 391)
@@ -24,7 +24,7 @@
 };
 
 struct settings {
-    unsigned int maxbytes;
+    size_t maxbytes;
     int maxconns;
     int port;
     struct in_addr interface;
@@ -157,7 +157,7 @@
 /* slabs memory allocation */
 
 /* Init the subsystem. The argument is the limit on no. of bytes to allocate, 0 if no limit */
-void slabs_init(unsigned int limit);
+void slabs_init(size_t limit);
 
 /* Preallocate as many slab pages as possible (called from slabs_init)
    on start-up, so users don't get confused out-of-memory errors when

Modified: branches/memcached-1.1.x/slabs.c
===================================================================
--- branches/memcached-1.1.x/slabs.c	2006-09-09 20:25:35 UTC (rev 390)
+++ branches/memcached-1.1.x/slabs.c	2006-09-09 20:36:57 UTC (rev 391)
@@ -49,8 +49,8 @@
 } slabclass_t;
 
 static slabclass_t slabclass[POWER_LARGEST+1];
-static unsigned int mem_limit = 0;
-static unsigned int mem_malloced = 0;
+static size_t mem_limit = 0;
+static size_t mem_malloced = 0;
 
 unsigned int slabs_clsid(unsigned int size) {
     int res = 1;
@@ -67,7 +67,7 @@
     return res;
 }
 
-void slabs_init(unsigned int limit) {
+void slabs_init(size_t limit) {
     int i;
     int size=1;
 
@@ -84,7 +84,22 @@
         slabclass[i].killing = 0;
     }
 
-    slabs_preallocate(limit / POWER_BLOCK);
+    /* for the test suite:  faking of how much we've already malloc'd */
+    {
+        char *t_initial_malloc = getenv("T_MEMD_INITIAL_MALLOC");
+        if (t_initial_malloc) {
+            mem_malloced = atol(getenv("T_MEMD_INITIAL_MALLOC"));
+        }
+    }
+
+    /* pre-allocate slabs by default, unless the environment variable
+       for testing is set to something non-zero */
+    {
+        char *pre_alloc = getenv("T_MEMD_SLABS_ALLOC");
+        if (!pre_alloc || atoi(pre_alloc)) {
+            slabs_preallocate(limit / POWER_BLOCK);
+        }
+    }
 }
 
 void slabs_preallocate (unsigned int maxslabs) {




More information about the memcached-commits mailing list