On the ocsp-verification branch: Sync with trunk up to r1774385.

git-svn-id: https://svn.apache.org/repos/asf/serf/branches/ocsp-verification@1774386 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/buckets/hpack_buckets.c b/buckets/hpack_buckets.c
index 83f6174..693b2da 100644
--- a/buckets/hpack_buckets.c
+++ b/buckets/hpack_buckets.c
@@ -1402,7 +1402,7 @@
 
     serf__log(LOGLVL_INFO, SERF_LOGCOMP_PROTOCOL, __FILE__, ctx->config,
               "Parsed from HPACK: %.*s: %.*s\n",
-              ctx->key_size, ctx->key, ctx->val_size, ctx->val);
+              (int)ctx->key_size, ctx->key, (int)ctx->val_size, ctx->val);
 
     if (!ctx->headers)
     {
diff --git a/buckets/log_wrapper_buckets.c b/buckets/log_wrapper_buckets.c
index 74193ad..440b67e 100644
--- a/buckets/log_wrapper_buckets.c
+++ b/buckets/log_wrapper_buckets.c
@@ -61,7 +61,7 @@
         serf__log(LOGLVL_DEBUG, LOGCOMP_CONN, ctx->prefix, ctx->config,
                   "--- %"APR_SIZE_T_FMT" bytes. --\n", *len);
         serf__log(LOGLVL_DEBUG, LOGCOMP_RAWMSG, ctx->prefix, ctx->config,
-                  "%.*s\n", *len, *data);
+                  "%.*s\n", (int)*len, *data);
     }
 
     return status;
@@ -93,7 +93,7 @@
 
     for (i = 0; i < *vecs_used; i++) {
         serf__log_nopref(LOGLVL_DEBUG, LOGCOMP_RAWMSG, ctx->config,
-                         "%.*s", vecs[i].iov_len, vecs[i].iov_base);
+                         "%.*s", (int)vecs[i].iov_len, vecs[i].iov_base);
     }
     serf__log_nopref(LOGLVL_DEBUG, LOGCOMP_RAWMSG, ctx->config, "\n");
 
@@ -116,7 +116,7 @@
         serf__log(LOGLVL_DEBUG, LOGCOMP_CONN, ctx->prefix, ctx->config,
                   "--- %"APR_SIZE_T_FMT" bytes. --\n", *len);
         serf__log(LOGLVL_DEBUG, LOGCOMP_RAWMSG, ctx->prefix, ctx->config,
-                  "%.*s\n", *len, *data);
+                  "%.*s\n", (int)*len, *data);
     }
 
     return status;
diff --git a/buckets/mmap_buckets.c b/buckets/mmap_buckets.c
index 2c3d723..6d2f15a 100644
--- a/buckets/mmap_buckets.c
+++ b/buckets/mmap_buckets.c
@@ -55,7 +55,7 @@
 {
     mmap_context_t *ctx = bucket->data;
     apr_status_t status;
-    char *rd;
+    void *rd;
 
     if (requested == SERF_READ_ALL_AVAIL || requested > ctx->remaining) {
         *len = ctx->remaining;
@@ -87,18 +87,19 @@
 {
     mmap_context_t *ctx = bucket->data;
     apr_status_t status;
-    char *end;
+    const char *eol;
+    void *end;
 
     /* ### Would it be faster to call this once and do the offset ourselves? */
     status = apr_mmap_offset(&end, ctx->mmap, ctx->offset);
     if (SERF_BUCKET_READ_ERROR(status))
         return status;
 
-    *data = end;
+    *data = eol = end;
 
     *len = ctx->remaining;
-    serf_util_readline(&end, len, acceptable, found);
-    *len = end - *data;
+    serf_util_readline(&eol, len, acceptable, found);
+    *len = eol - *data;
 
     ctx->offset += *len;
     ctx->remaining -= *len;
@@ -115,7 +116,7 @@
 {
     mmap_context_t *ctx = bucket->data;
     apr_status_t status;
-    char *rd;
+    void *rd;
 
     /* return whatever we have left */
     status = apr_mmap_offset(&rd, ctx->mmap, ctx->offset);
diff --git a/buckets/ssl_buckets.c b/buckets/ssl_buckets.c
index 2907ad7..cd2b0b2 100644
--- a/buckets/ssl_buckets.c
+++ b/buckets/ssl_buckets.c
@@ -1134,7 +1134,7 @@
         *len = ssl_len;
         status = ctx->crypt_status;
         serf__log(LOGLVL_DEBUG, LOGCOMP_SSLMSG, __FILE__, ctx->config,
-                    "---\n%.*s\n-(%"APR_SIZE_T_FMT")-\n", *len, buf, *len);
+                  "---\n%.*s\n-(%"APR_SIZE_T_FMT")-\n", (int)*len, buf, *len);
     }
 
 
@@ -1301,7 +1301,7 @@
 
                     serf__log(LOGLVL_DEBUG, LOGCOMP_SSL, __FILE__, ctx->config,
                               "---\n%.*s\n-(%"APR_SIZE_T_FMT")-\n",
-                              interim_len, vecs_data, interim_len);
+                              (int)interim_len, vecs_data, interim_len);
 
                 }
             }
@@ -1938,6 +1938,12 @@
     return context->selected_protocol;
 }
 
+/* Pool cleanup function for certificates */
+static apr_status_t free_ssl_cert(void *data)
+{
+    X509_free(data);
+    return APR_SUCCESS;
+}
 
 apr_status_t serf_ssl_use_default_certificates(serf_ssl_context_t *ssl_ctx)
 {
@@ -1981,10 +1987,12 @@
     bio_meth_free(biom);
 
     if (ssl_cert) {
-        /* TODO: Setup pool cleanup to free certificate */
         *cert = apr_palloc(pool, sizeof(serf_ssl_certificate_t));
         (*cert)->ssl_cert = ssl_cert;
 
+        apr_pool_cleanup_register(pool, ssl_cert, free_ssl_cert,
+                                  apr_pool_cleanup_null);
+
         return APR_SUCCESS;
     }
 #if 0