]> granicus.if.org Git - apache/commitdiff
BUCKETS SMS PHASE 1
authorCliff Woolley <jwoolley@apache.org>
Sat, 25 Aug 2001 22:56:22 +0000 (22:56 +0000)
committerCliff Woolley <jwoolley@apache.org>
Sat, 25 Aug 2001 22:56:22 +0000 (22:56 +0000)
Update to match apr-util

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@90664 13f79535-47bb-0310-9956-ffa450edef68

include/http_protocol.h
server/error_bucket.c

index b2754ed910e5daaf0784a977d49ac378145c8bff..d3065f672c11f2784fa146ffcb318c62b3046051 100644 (file)
@@ -597,6 +597,8 @@ struct ap_bucket_error {
     int status;
     /** The error string */
     const char    *data;
+    /** The SMS from which this structure was allocated */
+    apr_sms_t *sms;
 };
 
 AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error;
index 6484feb2b9052727098fb0f3d952444d0f4cce6e..dc75a3d0db3686f5a763e09d24c532c80517d1e0 100644 (file)
@@ -68,17 +68,20 @@ static apr_status_t error_read(apr_bucket *b, const char **str,
     return APR_SUCCESS;
 }
 
+static void error_destroy(void *data) {
+    ap_bucket_error *h;
+    apr_sms_free(h->sms, h);
+}
+
 AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error, 
                const char *buf, apr_pool_t *p)
 {
     ap_bucket_error *h;
 
-    h = malloc(sizeof(*h));
-    if (h == NULL) {
-        return NULL;
-    }
+    h = (ap_bucket_error *)apr_sms_malloc(b->sms, sizeof(*h));
     h->status = error;
     h->data = (buf) ? apr_pstrdup(p, buf) : NULL;
+    h->sms = b->sms;
 
     b->length = 0;
     b->start  = 0;
@@ -90,16 +93,22 @@ AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
 AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, 
                const char *buf, apr_pool_t *p)
 {
-    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
-
+    apr_sms_t *sms;
+    apr_bucket *b;
+    
+    if (!apr_bucket_global_sms) {
+        apr_sms_std_create(&apr_bucket_global_sms);
+    }
+    sms = apr_bucket_global_sms;
+    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
     APR_BUCKET_INIT(b);
-    b->free = free;
+    b->sms = sms;
     return ap_bucket_error_make(b, error, buf, p);
 }
 
 AP_DECLARE_DATA const apr_bucket_type_t ap_bucket_type_error = {
     "ERROR", 5,
-    free,
+    error_destroy,
     error_read,
     apr_bucket_setaside_notimpl,
     apr_bucket_split_notimpl,