Coverage Report

Created: 2023-03-26 06:28

/src/httpd/srclib/apr/buckets/apr_buckets_refcount.c
Line
Count
Source (jump to first uncovered line)
1
/* Licensed to the Apache Software Foundation (ASF) under one or more
2
 * contributor license agreements.  See the NOTICE file distributed with
3
 * this work for additional information regarding copyright ownership.
4
 * The ASF licenses this file to You under the Apache License, Version 2.0
5
 * (the "License"); you may not use this file except in compliance with
6
 * the License.  You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
17
#include "apr_buckets.h"
18
19
APR_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *a,
20
                                                         apr_size_t point)
21
9.22k
{
22
9.22k
    apr_bucket_refcount *r = a->data;
23
9.22k
    apr_status_t rv;
24
25
9.22k
    if ((rv = apr_bucket_simple_split(a, point)) != APR_SUCCESS) {
26
0
        return rv;
27
0
    }
28
9.22k
    r->refcount++;
29
30
9.22k
    return APR_SUCCESS;
31
9.22k
}
32
33
APR_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_copy(apr_bucket *a,
34
                                                        apr_bucket **b)
35
0
{
36
0
    apr_bucket_refcount *r = a->data;
37
38
0
    r->refcount++;
39
40
0
    return apr_bucket_simple_copy(a, b);
41
0
}
42
43
APR_DECLARE(int) apr_bucket_shared_destroy(void *data)
44
10.6k
{
45
10.6k
    apr_bucket_refcount *r = data;
46
10.6k
    r->refcount--;
47
10.6k
    return (r->refcount == 0);
48
10.6k
}
49
50
APR_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data,
51
                                                 apr_off_t start,
52
                                                 apr_size_t length)
53
1.37k
{
54
1.37k
    apr_bucket_refcount *r = data;
55
56
1.37k
    b->data   = r;
57
1.37k
    b->start  = start;
58
1.37k
    b->length = length;
59
    /* caller initializes the type field */
60
1.37k
    r->refcount = 1;
61
62
1.37k
    return b;
63
1.37k
}