当前位置: 首页>>代码示例>>C++>>正文


C++ STAILQ_EMPTY函数代码示例

本文整理汇总了C++中STAILQ_EMPTY函数的典型用法代码示例。如果您正苦于以下问题:C++ STAILQ_EMPTY函数的具体用法?C++ STAILQ_EMPTY怎么用?C++ STAILQ_EMPTY使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了STAILQ_EMPTY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _mbuf_get

static struct mbuf *
_mbuf_get(void)
{
    struct mbuf *mbuf;
    uint8_t *buf;

    if (!STAILQ_EMPTY(&free_mbufq)) {
        ASSERT(nfree_mbufq > 0);

        mbuf = STAILQ_FIRST(&free_mbufq);
        nfree_mbufq--;
        STAILQ_REMOVE_HEAD(&free_mbufq, next);

        ASSERT(mbuf->magic == MBUF_MAGIC);
        goto done;
    }

    buf = nc_alloc(mbuf_chunk_size);
    if (buf == NULL) {
        return NULL;
    }

#if 1 //shenzheng 2015-3-23 common
#ifdef NC_DEBUG_LOG
	ntotal_mbuf ++;
#endif
#endif //shenzheng 2015-3-23 common

    /*
     * mbuf header is at the tail end of the mbuf. This enables us to catch
     * buffer overrun early by asserting on the magic value during get or
     * put operations
     *
     *   <------------- mbuf_chunk_size ------------->
     *   +-------------------------------------------+
     *   |       mbuf data          |  mbuf header   |
     *   |     (mbuf_offset)        | (struct mbuf)  |
     *   +-------------------------------------------+
     *   ^           ^        ^     ^^
     *   |           |        |     ||
     *   \           |        |     |\
     *   mbuf->start \        |     | mbuf->end (one byte past valid bound)
     *                mbuf->pos     \
     *                        \      mbuf
     *                        mbuf->last (one byte past valid byte)
     *
     */
    mbuf = (struct mbuf *)(buf + mbuf_offset);
    mbuf->magic = MBUF_MAGIC;

done:
    STAILQ_NEXT(mbuf, next) = NULL;
    return mbuf;
}
开发者ID:7758285,项目名称:twemproxy-vip,代码行数:54,代码来源:nc_mbuf.c

示例2: elf_newscn

Elf_Scn *
elf_newscn(Elf *e)
{
	int ec;
	void *ehdr;
	Elf_Scn *scn;

	if (e == NULL || e->e_kind != ELF_K_ELF) {
		LIBELF_SET_ERROR(ARGUMENT, 0);
		return (NULL);
	}

	if ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64) {
		LIBELF_SET_ERROR(CLASS, 0);
		return (NULL);
	}

	if ((ehdr = _libelf_ehdr(e, ec, 0)) == NULL)
		return (NULL);

	/*
	 * The application may be asking for a new section descriptor
	 * on an ELF object opened with ELF_C_RDWR or ELF_C_READ.  We
	 * need to bring in the existing section information before
	 * appending a new one to the list.
	 *
	 * Per the ELF(3) API, an application is allowed to open a
	 * file using ELF_C_READ, mess with its internal structure and
	 * use elf_update(...,ELF_C_NULL) to compute its new layout.
	 */
	if (e->e_cmd != ELF_C_WRITE &&
	    (e->e_flags & LIBELF_F_SHDRS_LOADED) == 0 &&
	    _libelf_load_section_headers(e, ehdr) == 0)
		return (NULL);

	if (STAILQ_EMPTY(&e->e_u.e_elf.e_scn)) {
		assert(e->e_u.e_elf.e_nscn == 0);
		if ((scn = _libelf_allocate_scn(e, (size_t) SHN_UNDEF)) ==
		    NULL)
			return (NULL);
		e->e_u.e_elf.e_nscn++;
	}

	assert(e->e_u.e_elf.e_nscn > 0);

	if ((scn = _libelf_allocate_scn(e, e->e_u.e_elf.e_nscn)) == NULL)
		return (NULL);

	e->e_u.e_elf.e_nscn++;

	(void) elf_flagscn(scn, ELF_C_SET, ELF_F_DIRTY);

	return (scn);
}
开发者ID:rainaby,项目名称:elftoolchain-mirror,代码行数:54,代码来源:elf_scn.c

示例3: mbaqueue

/*
 * A device calls mbaqueue() when it wants to get on the adapter queue.
 * Called at splbio(). If the adapter is inactive, start it. 
 */
void
mbaqueue(struct mba_device *md)
{
	struct mba_softc * const sc = md->md_mba;
	bool was_empty = STAILQ_EMPTY(&sc->sc_xfers);

	STAILQ_INSERT_TAIL(&sc->sc_xfers, md, md_link);

	if (was_empty)
		mbastart(sc);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:15,代码来源:mba.c

示例4: free_dellist

static void
free_dellist(struct dl_head *dl)
{
	struct deletion_list	*dl_entry;

	while (!STAILQ_EMPTY(dl)) {
		dl_entry = STAILQ_FIRST(dl);
		STAILQ_REMOVE_HEAD(dl, next);
		free(dl_entry);
	}
}
开发者ID:HonestQiao,项目名称:pkgng,代码行数:11,代码来源:clean.c

示例5: flowadv_add_entry

void
flowadv_add_entry(struct flowadv_fcentry *fce) {
    lck_mtx_lock_spin(&fadv_lock);
    STAILQ_INSERT_HEAD(&fadv_list, fce, fce_link);
    VERIFY(!STAILQ_EMPTY(&fadv_list));

    if (!fadv_active && fadv_thread != THREAD_NULL)
        wakeup_one((caddr_t)&fadv_list);

    lck_mtx_unlock(&fadv_lock);
}
开发者ID:wzw19890321,项目名称:xnu-1,代码行数:11,代码来源:flowadv.c

示例6: obj_free

void
obj_free(Obj_Entry *obj)
{
    Objlist_Entry *elm;

    if (obj->tls_done)
	free_tls_offset(obj);
    while (obj->needed != NULL) {
	Needed_Entry *needed = obj->needed;
	obj->needed = needed->next;
	free(needed);
    }
    while (!STAILQ_EMPTY(&obj->names)) {
	Name_Entry *entry = STAILQ_FIRST(&obj->names);
	STAILQ_REMOVE_HEAD(&obj->names, link);
	free(entry);
    }
    while (!STAILQ_EMPTY(&obj->dldags)) {
	elm = STAILQ_FIRST(&obj->dldags);
	STAILQ_REMOVE_HEAD(&obj->dldags, link);
	free(elm);
    }
    while (!STAILQ_EMPTY(&obj->dagmembers)) {
	elm = STAILQ_FIRST(&obj->dagmembers);
	STAILQ_REMOVE_HEAD(&obj->dagmembers, link);
	free(elm);
    }
    if (obj->vertab)
	free(obj->vertab);
    if (obj->origin_path)
	free(obj->origin_path);
    if (obj->z_origin)
	free(obj->rpath);
    if (obj->priv)
	free(obj->priv);
    if (obj->path)
	free(obj->path);
    if (obj->phdr_alloc)
	free((void *)obj->phdr);
    free(obj);
}
开发者ID:0265727207,项目名称:evandrix.github.com,代码行数:41,代码来源:map_object.c

示例7: server_eof

void server_eof(struct connection *server, const char *reason)
{
    LOG(WARN, "server eof");

    struct command *c;
    while (!STAILQ_EMPTY(&server->info->ready_queue)) {
        c = STAILQ_FIRST(&server->info->ready_queue);
        STAILQ_REMOVE_HEAD(&server->info->ready_queue, ready_next);
        STAILQ_NEXT(c, ready_next) = NULL;
        if (c->stale) {
            cmd_free(c);
        } else {
            cmd_mark_fail(c, reason);
        }
    }

    // remove unprocessed data
    struct mbuf *b = TAILQ_LAST(&server->info->data, mhdr);
    if (b != NULL && b->pos < b->last) {
        b->pos = b->last;
    }

    while (!STAILQ_EMPTY(&server->info->waiting_queue)) {
        c = STAILQ_FIRST(&server->info->waiting_queue);
        STAILQ_REMOVE_HEAD(&server->info->waiting_queue, waiting_next);
        STAILQ_NEXT(c, waiting_next) = NULL;
        mbuf_range_clear(server->ctx, c->rep_buf);
        if (c->stale) {
            cmd_free(c);
        } else {
            cmd_mark_fail(c, reason);
        }
    }

    event_deregister(&server->ctx->loop, server);

    // drop all unsent requests
    cmd_iov_free(&server->info->iov);
    conn_free(server);
    slot_create_job(SLOT_UPDATE);
}
开发者ID:BBGIP,项目名称:corvus,代码行数:41,代码来源:server.c

示例8: call_get

struct call *
call_get(struct conn *conn)
{
    struct call *call;
    uint32_t i;

    if (!STAILQ_EMPTY(&free_callq)) {
        ASSERT(nfree_callq > 0);

        call = STAILQ_FIRST(&free_callq);
        nfree_callq--;

        STAILQ_REMOVE_HEAD(&free_callq, call_tqe);
    } else {
        call = mcp_alloc(sizeof(*call));
        if (call == NULL) {
            return NULL;
        }
    }

    STAILQ_NEXT(call, call_tqe) = NULL;
    call->id = ++id;
    call->conn = conn;

    /* keyname, expiry and keylen are initialized later */
    call->req.send = 0;
    call->req.sent = 0;
    call->req.issue_start = 0.0;
    call->req.send_start = 0.0;
    call->req.send_stop = 0.0;
    for (i = 0; i < REQ_IOV_LEN; i++) {
        call->req.iov[i].iov_base = NULL;
        call->req.iov[i].iov_len = 0;
    }
    call->req.noreply = 0;
    call->req.sending = 0;

    call->rsp.recv_start = 0.0;
    call->rsp.rcvd = 0;
    call->rsp.rcurr = conn->buf;
    call->rsp.rsize = sizeof(conn->buf);
    call->rsp.pcurr = call->rsp.rcurr;
    call->rsp.start = NULL;
    call->rsp.end = NULL;
    call->rsp.type = 0;
    call->rsp.vlen = 0;
    call->rsp.parsed_line = 0;
    call->rsp.parsed_vlen = 0;

    log_debug(LOG_VVERB, "get call %p id %"PRIu64"", call, call->id);

    return call;
}
开发者ID:AsamQi,项目名称:twemperf,代码行数:53,代码来源:mcp_call.c

示例9:

struct mbuf *mbuf_queue_get(struct context *ctx, struct mhdr *q)
{
    struct mbuf *buf = NULL;

    if (!STAILQ_EMPTY(q)) buf = STAILQ_LAST(q, mbuf, next);

    if (buf == NULL || mbuf_full(buf)) {
        buf = mbuf_get(ctx);
        STAILQ_INSERT_TAIL(q, buf, next);
    }
    return buf;
}
开发者ID:shelwei,项目名称:corvus,代码行数:12,代码来源:mbuf.c

示例10: _mbuf_get

static struct mbuf *
_mbuf_get(void)
{
    struct mbuf *mbuf;
    uint8_t *buf;

    //loga("_mbuf_get, nfree_mbufq = %d", nfree_mbufq);

    if (!STAILQ_EMPTY(&free_mbufq)) {
        ASSERT(nfree_mbufq > 0);

        mbuf = STAILQ_FIRST(&free_mbufq);
        nfree_mbufq--;
        STAILQ_REMOVE_HEAD(&free_mbufq, next);

        ASSERT(mbuf->magic == MBUF_MAGIC);
        goto done;
    }

    buf = dn_alloc(mbuf_chunk_size);
    if (buf == NULL) {
        return NULL;
    }
    mbuf_alloc_count++;

    /*
     * mbuf header is at the tail end of the mbuf. This enables us to catch
     * buffer overrun early by asserting on the magic value during get or
     * put operations
     *
     *   <------------- mbuf_chunk_size ------------------------->
     *   +-------------------------------------------------------+
     *   |       mbuf data                      |  mbuf header   |
     *   |     (mbuf_offset)                    | (struct mbuf)  |
     *   +-------------------------------------------------------+
     *   ^           ^        ^      ^          ^^
     *   |           |        |      |          ||
     *   |           |        |      |          \ \mbuf->end_extra (one byte past valid bound)
     *   \           |        |      \           \
     *   mbuf->start \        |      mbuf->end    mbuf
     *             mbuf->pos  |
     *                        \
     *                       mbuf->last (one byte past valid byte)
     *
     */
    mbuf = (struct mbuf *)(buf + mbuf_offset);
    mbuf->magic = MBUF_MAGIC;
    mbuf->chunk_size = mbuf_chunk_size;

done:
    STAILQ_NEXT(mbuf, next) = NULL;
    return mbuf;
}
开发者ID:Aidanie,项目名称:dynomite,代码行数:53,代码来源:dyn_mbuf.c

示例11: sfb_fclists_clean

static void
sfb_fclists_clean(struct sfb *sp)
{
	int i;

	/* Move all the flow control entries to the flowadv list */
	for (i = 0; i < SFB_BINS; ++i) {
		struct sfb_fcl *fcl = SFB_FC_LIST(sp, i);
		if (!STAILQ_EMPTY(&fcl->fclist))
			sfb_fclist_append(sp, fcl);
	}
}
开发者ID:aglab2,项目名称:darwin-xnu,代码行数:12,代码来源:classq_sfb.c

示例12: conn_get

struct conn *
conn_get(struct context *ctx)
{
    struct conn *conn;

    if (!STAILQ_EMPTY(&free_connq)) {
        ASSERT(nfree_connq > 0);

        conn = STAILQ_FIRST(&free_connq);
        nfree_connq--;

        STAILQ_REMOVE_HEAD(&free_connq, conn_tqe);
    } else {
        conn = mcp_alloc(sizeof(*conn));
        if (conn == NULL) {
            return NULL;
        }
    }

    STAILQ_NEXT(conn, conn_tqe) = NULL;
    conn->id = ++id;
    conn->ctx = ctx;

    conn->ncall_sendq = 0;
    STAILQ_INIT(&conn->call_sendq);
    conn->ncall_recvq = 0;
    STAILQ_INIT(&conn->call_recvq);

    conn->watchdog = NULL;
    conn->connect_start = 0.0;

    conn->sd = -1;

    /* conn->call_gen is initialized later */
    conn->ncall_created = 0;
    conn->ncall_create_failed = 0;
    conn->ncall_completed = 0;

    conn->err = 0;
    conn->recv_active = 0;
    conn->recv_ready = 0;
    conn->send_active = 0;
    conn->send_ready = 0;

    conn->connecting = 0;
    conn->connected = 0;
    conn->eof = 0;

    log_debug(LOG_VVERB, "get conn %p id %"PRIu64"", conn, conn->id);

    return conn;
}
开发者ID:AsamQi,项目名称:twemperf,代码行数:52,代码来源:mcp_conn.c

示例13: mpc_url_deinit

void
mpc_url_deinit(void)
{
    mpc_url_t *mpc_url;

    while (!STAILQ_EMPTY(&mpc_url_free_queue)) {
        mpc_url = STAILQ_FIRST(&mpc_url_free_queue);
        mpc_url_remove(&mpc_url_free_queue, mpc_url);
        mpc_url_free(mpc_url);
        mpc_url_nfree--;
    }

    while (!STAILQ_EMPTY(&mpc_url_task_queue)) {
        mpc_url = STAILQ_FIRST(&mpc_url_task_queue);
        mpc_url_remove(&mpc_url_task_queue, mpc_url);
        mpc_url_free(mpc_url);
        mpc_url_ntask--;
    }

    ASSERT(mpc_url_nfree == 0);
//    ASSERT(mpc_url_ntask == 0);
}
开发者ID:flygoast,项目名称:mpc,代码行数:22,代码来源:mpc_url.c

示例14: mbuf_deinit

void
mbuf_deinit(void)
{
    while (!STAILQ_EMPTY(&free_mbufq)) {
        struct mbuf *mbuf = STAILQ_FIRST(&free_mbufq);
        mbuf_remove(&free_mbufq, mbuf);
        mbuf_free(mbuf);
        nfree_mbufq--;
		
#if 1 //shenzheng 2015-3-23 common
#ifdef NC_DEBUG_LOG
		ntotal_mbuf--;
#endif
#endif //shenzheng 2015-3-23 common

    }

#if 1 //shenzheng 2015-5-13 proxy administer
	while (!STAILQ_EMPTY(&free_mbufq_proxy_adm)) {
        struct mbuf *mbuf = STAILQ_FIRST(&free_mbufq_proxy_adm);
        mbuf_remove(&free_mbufq_proxy_adm, mbuf);
        mbuf_free(mbuf);
        nfree_mbufq_proxy_adm--;

#ifdef NC_DEBUG_LOG
		ntotal_mbuf_proxy_adm--;
#endif
	}
#endif //shenzheng 2015-5-13 proxy administer

    ASSERT(nfree_mbufq == 0);
	
#if 1 //shenzheng 2015-3-23 common
#ifdef NC_DEBUG_LOG
	ASSERT(ntotal_mbuf == 0);
#endif
#endif //shenzheng 2015-3-23 common

}
开发者ID:7758285,项目名称:twemproxy-vip,代码行数:39,代码来源:nc_mbuf.c

示例15: conn_close

rstatus_t
conn_close(struct conn *conn)
{
    rstatus_t status;
    struct mbuf *mbuf, *nbuf;            /* current and next mbuf */

    if (conn->fd < 0) {
        conn_put(conn);
        return NC_OK;
    }

    if (!STAILQ_EMPTY(&conn->recv_queue)) {
        log_warn("close conn %d discard data in send_queue", conn->fd);
        for (mbuf = STAILQ_FIRST(&conn->recv_queue); mbuf != NULL; mbuf = nbuf) {
            nbuf = STAILQ_NEXT(mbuf, next);
            mbuf_remove(&conn->recv_queue, mbuf);
            mbuf_put(mbuf);
        }
    }

    if (!STAILQ_EMPTY(&conn->send_queue)) {
        log_warn("close conn %d discard data in send_queue", conn->fd);
        for (mbuf = STAILQ_FIRST(&conn->send_queue); mbuf != NULL; mbuf = nbuf) {
            nbuf = STAILQ_NEXT(mbuf, next);
            mbuf_remove(&conn->send_queue, mbuf);
            mbuf_put(mbuf);
        }
    }

    status = close(conn->fd);
    if (status < 0) {
        log_error("close c %d failed, ignored: %s", conn->fd, strerror(errno));
    }
    conn->fd = -1;

    conn_put(conn);
    return NC_OK;
}
开发者ID:idning,项目名称:ndb,代码行数:38,代码来源:nc_connection.c


注:本文中的STAILQ_EMPTY函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。