本文整理汇总了C++中TAILQ_LAST函数的典型用法代码示例。如果您正苦于以下问题:C++ TAILQ_LAST函数的具体用法?C++ TAILQ_LAST怎么用?C++ TAILQ_LAST使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TAILQ_LAST函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: put_entry_d_sorted
static inline void put_entry_d_sorted(int row, int col, double value, size_t pos, queue_d *queue, cstuff_DirectionMap *obj, entry_d **waiting) {
entry_d *entry, *entry2, *entry3;
entry = waiting[pos];
if (entry) {
TAILQ_REMOVE(queue, entry, hook);
} else {
entry = get_entry_d(row, col, value);
waiting[pos] = entry;
}
entry->row = row;
entry->col = col;
entry->value = value;
obj->map->values[pos] = value;
if (TAILQ_EMPTY(queue) || TAILQ_LAST(queue, _queue_d)->value <= value) {
TAILQ_INSERT_TAIL(queue, entry, hook);
} else if (TAILQ_FIRST(queue)->value > value) {
TAILQ_INSERT_HEAD(queue, entry, hook);
} else {
entry2 = TAILQ_LAST(queue, _queue_d);
TAILQ_FOREACH_REVERSE(entry3, queue, _queue_d, hook) {
if (entry3->value > value) {
entry2 = entry3;
} else {
break;
}
}
TAILQ_INSERT_BEFORE(entry2, entry, hook);
}
}
示例2: cache_lfu_policy_get_prev_item
static struct cache_policy_item_ *
cache_lfu_policy_get_prev_item(struct cache_policy_ *policy,
struct cache_policy_item_ *item)
{
struct cache_lfu_policy_ *lfu_policy;
struct cache_lfu_policy_item_ *lfu_item;
int i;
TRACE_IN(cache_lfu_policy_get_prev_item);
lfu_policy = (struct cache_lfu_policy_ *)policy;
lfu_item = TAILQ_PREV((struct cache_lfu_policy_item_ *)item,
cache_lfu_policy_group_, entries);
if (lfu_item == NULL)
{
for (i = ((struct cache_lfu_policy_item_ *)item)->frequency - 1;
i >= 0; --i)
if (!TAILQ_EMPTY(&(lfu_policy->groups[i]))) {
lfu_item = TAILQ_LAST(&(lfu_policy->groups[i]),
cache_lfu_policy_group_);
break;
}
}
TRACE_OUT(cache_lfu_policy_get_prev_item);
return ((struct cache_policy_item_ *)lfu_item);
}
示例3: load_one
/**
* load_one - Load one plugin
* @path: Path to finit plugins, usually %PLUGIN_PATH
* @name: Name of plugin, optionally ending in ".so"
*
* Loads a plugin from @path/@name[.so]. Note, if ".so" is missing from
* the plugin @name it is added before attempting to load.
*
* It is up to the plugin itself ot register itself as a "ctor" with the
* %PLUGIN_INIT macro so that plugin_register() is called automatically.
*
* Returns:
* POSIX OK(0) on success, non-zero otherwise.
*/
static int load_one(char *path, char *name)
{
int noext;
char sofile[CMD_SIZE];
void *handle;
plugin_t *plugin;
if (!path || !fisdir(path) || !name) {
errno = EINVAL;
return 1;
}
/* Compose full path, with optional .so extension, to plugin */
noext = strcmp(name + strlen(name) - 3, ".so");
snprintf(sofile, sizeof(sofile), "%s/%s%s", path, name, noext ? ".so" : "");
_d("Loading plugin %s ...", basename(sofile));
handle = dlopen(sofile, RTLD_LAZY | RTLD_LOCAL);
if (!handle) {
_e("Failed loading plugin %s: %s", sofile, dlerror());
return 1;
}
plugin = TAILQ_LAST(&plugins, plugin_head);
if (!plugin) {
_e("Plugin %s failed to register, unloading from memory", sofile);
dlclose(handle);
return 1;
}
/* Remember handle from dlopen() for plugin_unregister() */
plugin->handle = handle;
return 0;
}
示例4: db_exist
/*
* db_exist --
* Return if a line exists.
*
* PUBLIC: int db_exist(SCR *, recno_t);
*/
int
db_exist(
SCR *sp,
recno_t lno)
{
EXF *ep;
/* Check for no underlying file. */
if ((ep = sp->ep) == NULL) {
ex_emsg(sp, NULL, EXM_NOFILEYET);
return (1);
}
if (lno == OOBLNO)
return (0);
/*
* Check the last-line number cache. Adjust the cached line
* number for the lines used by the text input buffers.
*/
if (ep->c_nlines != OOBLNO)
return (lno <= (F_ISSET(sp, SC_TINPUT) ?
ep->c_nlines + (((TEXT *)TAILQ_LAST(sp->tiq, _texth))->lno -
((TEXT *)TAILQ_FIRST(sp->tiq))->lno) : ep->c_nlines));
/* Go get the line. */
return (!db_get(sp, lno, 0, NULL, NULL));
}
示例5: del_panel
int
del_panel(PANEL *p)
{
if (__predict_false(p == NULL))
return ERR;
(void) hide_panel(p);
free(p);
/*
* If the last panel is removed, remove the phantom stdscr
* panel as well.
*
* A program that wants to switch to a different screen with
* set_term(3), or ends and recreates curses session with
* endwin(3)/initscr(3), must delete all panels first, since
* their windows will become invalid. When it will create its
* first new panel afterwards, it will pick up new stdscr.
*/
if (TAILQ_LAST(&_deck, deck) == &_stdscr_panel) {
(void) hide_panel(&_stdscr_panel);
assert(TAILQ_EMPTY(&_deck));
}
return OK;
}
示例6: trace_enter
int
trace_enter(int fd, char *line, int closed)
{
struct trace *tmp;
int res;
assert(fd >= 0);
if (trace_refs == NULL || fd >= trace_refsize) {
res = trace_init(fd);
if (res == -1)
goto error;
}
if ((tmp = TAILQ_LAST(trace_refs[fd], traceq)) != NULL) {
if (tmp->closed)
trace_free(fd);
}
if ((tmp = malloc(sizeof(struct trace))) == NULL)
goto error;
tmp->line = line;
tmp->closed = closed;
TAILQ_INSERT_TAIL(trace_refs[fd], tmp, next);
return (0);
error:
free(line);
return (-1);
}
示例7: tag_new
struct tag*
tag_new(struct screen *s, char *name)
{
struct tag *t, *l;
t = xcalloc(1, sizeof(struct tag));
t->screen = s;
t->flags = 0;
t->id = 0;
t->sel = NULL;
t->prev = NULL;
if((l = TAILQ_LAST(&s->tags, tsub)))
t->id = l->id + 1;
if(!name || !strlen(name))
xasprintf(&t->name, "%d", t->id + 1);
else
t->name = xstrdup(name);
SLIST_INIT(&t->clients);
TAILQ_INIT(&t->sets);
TAILQ_INSERT_TAIL(&s->tags, t, next);
return t;
}
示例8: imageboot_setup
int
imageboot_setup()
{
dev_t dev;
int error = 0;
char *root_path = NULL;
DBG_TRACE("%s: entry\n", __FUNCTION__);
MALLOC_ZONE(root_path, caddr_t, MAXPATHLEN, M_NAMEI, M_WAITOK);
if (root_path == NULL)
return (ENOMEM);
if(PE_parse_boot_argn("rp", root_path, MAXPATHLEN) == FALSE) {
error = ENOENT;
goto done;
}
printf("%s: root image url is %s\n", __FUNCTION__, root_path);
error = di_root_image(root_path, rootdevice, &dev);
if(error) {
printf("%s: di_root_image failed: %d\n", __FUNCTION__, error);
goto done;
}
rootdev = dev;
mountroot = NULL;
printf("%s: root device 0x%x\n", __FUNCTION__, rootdev);
error = vfs_mountroot();
if (error == 0 && rootvnode != NULL) {
struct vnode *tvp;
struct vnode *newdp;
/*
* Get the vnode for '/'.
* Set fdp->fd_fd.fd_cdir to reference it.
*/
if (VFS_ROOT(TAILQ_LAST(&mountlist,mntlist), &newdp, vfs_context_kernel()))
panic("%s: cannot find root vnode", __FUNCTION__);
vnode_ref(newdp);
vnode_put(newdp);
tvp = rootvnode;
vnode_rele(tvp);
filedesc0.fd_cdir = newdp;
rootvnode = newdp;
mount_list_lock();
TAILQ_REMOVE(&mountlist, TAILQ_FIRST(&mountlist), mnt_list);
mount_list_unlock();
mountlist.tqh_first->mnt_flag |= MNT_ROOTFS;
DBG_TRACE("%s: root switched\n", __FUNCTION__);
}
done:
FREE_ZONE(root_path, MAXPATHLEN, M_NAMEI);
DBG_TRACE("%s: exit\n", __FUNCTION__);
return (error);
}
示例9: main
int main()
{
int i;
struct type tmp[20];
struct type *echo;
//step 1: init
TAILQ_INIT(&header);
//step 2: insert item
for (i = 0; i < strlen(name); i++) {
tmp[i].c = *(name + i);
tmp[i].list.tqe_next = NULL;
tmp[i].list.tqe_prev = NULL;
TAILQ_INSERT_TAIL(&header, &tmp[i], list);
}
//step 3 : get element.
#if defined(_FIFO_)
while ((echo = TAILQ_FIRST(&header)) != NULL) {
#elif defined(_FILO_)
while ((echo = TAILQ_LAST(&header, head_)) != NULL){
#endif
printf("%2c", echo->c);
TAILQ_REMOVE(&header, echo, list);
}
printf("\n");
return 0;
}
示例10: TAILQ_LAST
/*
* Get the newest file
*/
timeshift_file_t *timeshift_filemgr_newest ( timeshift_t *ts )
{
timeshift_file_t *tsf = TAILQ_LAST(&ts->files, timeshift_file_list);
if (tsf)
tsf->refcount++;
return tsf;
}
示例11: nav_close_all
static void
nav_close_all(navigator_t *nav, int with_prop)
{
nav_page_t *np;
while((np = TAILQ_LAST(&nav->nav_pages, nav_page_queue)) != NULL)
nav_close(np, with_prop);
}
示例12: hg_queue_peek_tail
/*---------------------------------------------------------------------------*/
hg_queue_value_t
hg_queue_peek_tail(hg_queue_t *queue)
{
if (!queue || hg_queue_is_empty(queue))
return HG_QUEUE_NULL;
else
return TAILQ_LAST(queue, hg_queue)->data;
}
示例13: ava_intr_loopctl_subst
static ava_macro_subst_result ava_intr_loopctl_subst(
const struct ava_symbol_s* self,
ava_macsub_context* context,
const ava_parse_statement* statement,
const ava_parse_unit* provoker,
ava_bool* consumed_other_statements,
ava_bool is_break
) {
ava_intr_loopctl* this;
const ava_parse_unit* unit;
this = AVA_NEW(ava_intr_loopctl);
this->header.v = &ava_intr_loopctl_vtable;
this->header.location = provoker->location;
this->header.context = context;
this->is_break = is_break;
this->suppress_write_back = ava_false;
this->expression = NULL;
for (unit = TAILQ_NEXT(provoker, next); unit;
unit = TAILQ_NEXT(unit, next)) {
if (ava_put_bareword != unit->type ||
ava_string_is_empty(unit->v.string) ||
'-' != ava_string_index(unit->v.string, 0))
/* Not a flag */
break;
switch (ava_string_to_ascii9(unit->v.string)) {
case AVA_ASCII9('-'):
if (this->suppress_write_back)
return ava_macsub_error_result(
context, ava_error_loopctl_flag_more_than_once(
&unit->location, self->full_name, unit->v.string));
this->suppress_write_back = ava_true;
break;
default:
return ava_macsub_error_result(
context, ava_error_bad_loopctl_flag(
&unit->location, self->full_name, unit->v.string));
}
}
if (unit) {
if (this->suppress_write_back)
return ava_macsub_error_result(
context, ava_error_loopctl_expression_but_suppressed(
&unit->location));
this->expression = ava_macsub_run_units(
context, unit, TAILQ_LAST(&statement->units, ava_parse_unit_list_s));
}
return (ava_macro_subst_result) {
.status = ava_mss_done,
.v = { .node = (ava_ast_node*)this },
};
}
示例14: net_send_queue
void
net_send_queue(struct connection *c, void *data, u_int32_t len,
struct spdy_stream *s, int before)
{
u_int8_t *d;
struct netbuf *nb;
u_int32_t avail;
kore_debug("net_send_queue(%p, %p, %d, %p, %d)",
c, data, len, s, before);
d = data;
if (before == NETBUF_LAST_CHAIN) {
nb = TAILQ_LAST(&(c->send_queue), netbuf_head);
if (nb != NULL && !(nb->flags & NETBUF_IS_STREAM) &&
nb->stream == s && nb->b_len < nb->m_len) {
avail = nb->m_len - nb->b_len;
if (len < avail) {
memcpy(nb->buf + nb->b_len, d, len);
nb->b_len += len;
return;
} else if (len > avail) {
memcpy(nb->buf + nb->b_len, d, avail);
nb->b_len += avail;
len -= avail;
d += avail;
if (len == 0)
return;
}
}
}
nb = kore_pool_get(&nb_pool);
nb->flags = 0;
nb->cb = NULL;
nb->owner = c;
nb->s_off = 0;
nb->stream = s;
nb->b_len = len;
nb->type = NETBUF_SEND;
if (nb->b_len < NETBUF_SEND_PAYLOAD_MAX)
nb->m_len = NETBUF_SEND_PAYLOAD_MAX;
else
nb->m_len = nb->b_len;
nb->buf = kore_malloc(nb->m_len);
if (len > 0)
memcpy(nb->buf, d, nb->b_len);
if (before == NETBUF_BEFORE_CHAIN) {
TAILQ_INSERT_BEFORE(c->snb, nb, list);
} else {
TAILQ_INSERT_TAIL(&(c->send_queue), nb, list);
}
}
示例15: test_frag
static int
test_frag(char *overlap, int drop)
{
struct timeval tv, save_tv = read_tv;
struct pkt *pkt;
struct icmp_msg_echo *echo;
char *frag_argv[4];
if (overlap != NULL)
printf("frag-%s: ", overlap);
else if (drop)
printf("frag-timeout (please wait): ");
else
printf("frag: ");
fflush(stdout);
ping->pkt_ip->ip_id = rand_uint16(ctx.rnd);
ping->pkt_icmp_msg->echo.icmp_id = rand_uint16(ctx.rnd);
pkt = pkt_dup(ping);
ip_checksum(pkt->pkt_ip, pkt->pkt_end - pkt->pkt_eth_data);
TAILQ_INSERT_TAIL(&ctx.pktq, pkt, pkt_next);
frag_argv[0] = "ip_frag";
frag_argv[1] = "8";
frag_argv[2] = overlap;
frag_argv[3] = NULL;
mod_ip_frag.open(overlap ? 3 : 2, frag_argv, NULL);
mod_ip_frag.apply(NULL, &ctx.pktq, NULL);
if (drop) {
pkt = TAILQ_LAST(&ctx.pktq, pktq);
TAILQ_REMOVE(&ctx.pktq, pkt, pkt_next);
pkt_free(pkt);
save_tv.tv_sec = FRAG_TIMEOUT;
}
pcap_filter(ctx.pcap, "icmp[0] = %d and src %s and dst %s",
drop ? 11 : 0, addr_ntoa(&ctx.dst), addr_ntoa(&ctx.src));
send_pktq(&ctx.pktq);
for (tv = save_tv; (pkt = recv_pkt(&tv)) != NULL; tv = save_tv) {
if (drop) {
echo = (struct icmp_msg_echo *)
(pkt->pkt_icmp_msg->timexceed.icmp_ip +
IP_HDR_LEN + ICMP_HDR_LEN);
} else {
echo = &pkt->pkt_icmp_msg->echo;
}
if (echo->icmp_id == ping->pkt_icmp_msg->echo.icmp_id)
break;
}
printf("%s\n", pkt ? timeval_ntoa(&tv) : "no reply");
return (0);
}