资源简介
apr-util-1.3.12.tar.gz
代码片段和文件信息
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License Version 2.0
* (the “License“); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include “apr.h“
#include “apr_lib.h“
#include “apr_strings.h“
#include “apr_pools.h“
#include “apr_tables.h“
#include “apr_buckets.h“
#include “apr_errno.h“
#define APR_WANT_MEMFUNC
#define APR_WANT_STRFUNC
#include “apr_want.h“
#if APR_HAVE_SYS_UIO_H
#include
#endif
static apr_status_t brigade_cleanup(void *data)
{
return apr_brigade_cleanup(data);
}
APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data)
{
apr_bucket_brigade *b = data;
apr_bucket *e;
while (!APR_BRIGADE_EMPTY(b)) {
e = APR_BRIGADE_FIRST(b);
apr_bucket_delete(e);
}
/* We don‘t need to free(bb) because it‘s allocated from a pool. */
return APR_SUCCESS;
}
APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b)
{
apr_pool_cleanup_kill(b->p b brigade_cleanup);
return apr_brigade_cleanup(b);
}
APU_DECLARE(apr_bucket_brigade *) apr_brigade_create(apr_pool_t *p
apr_bucket_alloc_t *list)
{
apr_bucket_brigade *b;
b = apr_palloc(p sizeof(*b));
b->p = p;
b->bucket_alloc = list;
APR_RING_INIT(&b->list apr_bucket link);
apr_pool_cleanup_register(b->p b brigade_cleanup apr_pool_cleanup_null);
return b;
}
APU_DECLARE(apr_bucket_brigade *) apr_brigade_split_ex(apr_bucket_brigade *b
apr_bucket *e
apr_bucket_brigade *a)
{
apr_bucket *f;
if (!a) {
a = apr_brigade_create(b->p b->bucket_alloc);
}
else if (!APR_BRIGADE_EMPTY(a)) {
apr_brigade_cleanup(a);
}
/* Return an empty brigade if there is nothing left in
* the first brigade to split off
*/
if (e != APR_BRIGADE_SENTINEL(b)) {
f = APR_RING_LAST(&b->list);
APR_RING_UNSPLICE(e f link);
APR_RING_SPLICE_HEAD(&a->list e f apr_bucket link);
}
APR_BRIGADE_CHECK_CONSISTENCY(a);
APR_BRIGADE_CHECK_CONSISTENCY(b);
return a;
}
APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b
apr_bucket *e)
{
return ap
评论
共有 条评论