Two changes at ones lead to a confused libeay.num. Fix
[openssl.git] / crypto / sec_mem.c
index 5bf8baace1d1ceb96bf271205cfddae4a7334b7c..fbed8b49fca655160f255cae7967b902453c167a 100644 (file)
@@ -26,7 +26,9 @@
 #define LOCK()      CRYPTO_w_lock(CRYPTO_LOCK_MALLOC)
 #define UNLOCK()    CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC)
 #define CLEAR(p, s) OPENSSL_cleanse(p, s)
-#define PAGE_SIZE    4096
+#ifndef PAGE_SIZE
+# define PAGE_SIZE    4096
+#endif
 
 #ifdef IMPLEMENTED
 size_t secure_mem_used;
@@ -312,23 +314,20 @@ static int sh_init(size_t size, int minsize)
     for (i = sh.bittable_size; i; i >>= 1)
         sh.freelist_size++;
 
-    sh.freelist = OPENSSL_malloc(sh.freelist_size * sizeof (char *));
+    sh.freelist = OPENSSL_zalloc(sh.freelist_size * sizeof (char *));
     OPENSSL_assert(sh.freelist != NULL);
     if (sh.freelist == NULL)
         goto err;
-    memset(sh.freelist, 0, sh.freelist_size * sizeof (char *));
 
-    sh.bittable = OPENSSL_malloc(sh.bittable_size >> 3);
+    sh.bittable = OPENSSL_zalloc(sh.bittable_size >> 3);
     OPENSSL_assert(sh.bittable != NULL);
     if (sh.bittable == NULL)
         goto err;
-    memset(sh.bittable, 0, sh.bittable_size >> 3);
 
-    sh.bitmalloc = OPENSSL_malloc(sh.bittable_size >> 3);
+    sh.bitmalloc = OPENSSL_zalloc(sh.bittable_size >> 3);
     OPENSSL_assert(sh.bitmalloc != NULL);
     if (sh.bitmalloc == NULL)
         goto err;
-    memset(sh.bitmalloc, 0, sh.bittable_size >> 3);
 
     /* Allocate space for heap, and two extra pages as guards */
 #ifdef _SC_PAGE_SIZE