Blame buckets/apr_buckets_refcount.c

Packit 383869
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 383869
 * contributor license agreements.  See the NOTICE file distributed with
Packit 383869
 * this work for additional information regarding copyright ownership.
Packit 383869
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 383869
 * (the "License"); you may not use this file except in compliance with
Packit 383869
 * the License.  You may obtain a copy of the License at
Packit 383869
 *
Packit 383869
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 383869
 *
Packit 383869
 * Unless required by applicable law or agreed to in writing, software
Packit 383869
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 383869
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 383869
 * See the License for the specific language governing permissions and
Packit 383869
 * limitations under the License.
Packit 383869
 */
Packit 383869
Packit 383869
#include "apr_buckets.h"
Packit 383869
Packit 383869
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *a,
Packit 383869
                                                         apr_size_t point)
Packit 383869
{
Packit 383869
    apr_bucket_refcount *r = a->data;
Packit 383869
    apr_status_t rv;
Packit 383869
Packit 383869
    if ((rv = apr_bucket_simple_split(a, point)) != APR_SUCCESS) {
Packit 383869
        return rv;
Packit 383869
    }
Packit 383869
    r->refcount++;
Packit 383869
Packit 383869
    return APR_SUCCESS;
Packit 383869
}
Packit 383869
Packit 383869
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_copy(apr_bucket *a,
Packit 383869
                                                        apr_bucket **b)
Packit 383869
{
Packit 383869
    apr_bucket_refcount *r = a->data;
Packit 383869
Packit 383869
    apr_bucket_simple_copy(a, b);
Packit 383869
    r->refcount++;
Packit 383869
Packit 383869
    return APR_SUCCESS;
Packit 383869
}
Packit 383869
Packit 383869
APU_DECLARE(int) apr_bucket_shared_destroy(void *data)
Packit 383869
{
Packit 383869
    apr_bucket_refcount *r = data;
Packit 383869
    r->refcount--;
Packit 383869
    return (r->refcount == 0);
Packit 383869
}
Packit 383869
Packit 383869
APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data,
Packit 383869
                                                 apr_off_t start,
Packit 383869
                                                 apr_size_t length)
Packit 383869
{
Packit 383869
    apr_bucket_refcount *r = data;
Packit 383869
Packit 383869
    b->data   = r;
Packit 383869
    b->start  = start;
Packit 383869
    b->length = length;
Packit 383869
    /* caller initializes the type field */
Packit 383869
    r->refcount = 1;
Packit 383869
Packit 383869
    return b;
Packit 383869
}