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


C++ RB_INSERT函数代码示例

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


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

示例1: format_add

/* Add a key-value pair. */
void
format_add(struct format_tree *ft, const char *key, const char *fmt, ...)
{
	struct format_entry	*fe;
	va_list			 ap;

	fe = xmalloc(sizeof *fe);
	fe->key = xstrdup(key);

	va_start(ap, fmt);
	xvasprintf(&fe->value, fmt, ap);
	va_end(ap);

	RB_INSERT(format_tree, ft, fe);
}
开发者ID:psych0tik,项目名称:tmux,代码行数:16,代码来源:format.c

示例2: ct_match_insert_rb

void
ct_match_insert_rb(struct ct_match *match, char *string)
{
	struct ct_match_node	*n;

	if (match->cm_mode != CT_MATCH_RB)
		CABORTX("match mode %d is not rb", match->cm_mode);
	n = e_calloc(1, sizeof(struct ct_match_node));
	n->cmn_string = e_strdup(string);
	if (RB_INSERT(ct_match_tree, match->cm_rb_head, n)) {
		/* pattern already exists free it */
		e_free(&n->cmn_string);
		e_free(&n);
	}
}
开发者ID:finid,项目名称:cyphertite,代码行数:15,代码来源:ct_match.c

示例3: ramstat_set

static void
ramstat_set(const char *name, const struct stat_value *val)
{
	struct ramstat_entry	*np, lk;

	log_trace(TRACE_STAT, "ramstat: set: %s", name);
	(void)strlcpy(lk.key, name, sizeof (lk.key));
	np = RB_FIND(stats_tree, &stats, &lk);
	if (np == NULL) {
		np = xcalloc(1, sizeof *np, "ramstat_set");
		(void)strlcpy(np->key, name, sizeof (np->key));
		RB_INSERT(stats_tree, &stats, np);
	}
	log_trace(TRACE_STAT, "ramstat: %s: n/a -> n/a", name);
	np->value = *val;
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:16,代码来源:stat_ramstat.c

示例4: uv_signal_start

int uv_signal_start(uv_signal_t* handle, uv_signal_cb signal_cb, int signum) {
  uv_err_t err;

  /* If the user supplies signum == 0, then return an error already. If the */
  /* signum is otherwise invalid then uv__signal_register will find out */
  /* eventually. */
  if (signum == 0) {
    uv__set_artificial_error(handle->loop, UV_EINVAL);
    return -1;
  }

  /* Short circuit: if the signal watcher is already watching {signum} don't */
  /* go through the process of deregistering and registering the handler. */
  /* Additionally, this avoids pending signals getting lost in the (small) */
  /* time frame that handle->signum == 0. */
  if (signum == handle->signum) {
    handle->signal_cb = signal_cb;
    return 0;
  }

  /* If the signal handler was already active, stop it first. */
  if (handle->signum != 0) {
    int r = uv_signal_stop(handle);
    /* uv_signal_stop is infallible. */
    assert(r == 0);
  }

  EnterCriticalSection(&uv__signal_lock);

  err = uv__signal_register(signum);
  if (err.code != UV_OK) {
    /* Uh-oh, didn't work. */
    handle->loop->last_err = err;
    LeaveCriticalSection(&uv__signal_lock);
    return -1;
  }

  handle->signum = signum;
  RB_INSERT(uv_signal_tree_s, &uv__signal_tree, handle);

  LeaveCriticalSection(&uv__signal_lock);

  handle->signal_cb = signal_cb;
  uv__handle_start(handle);

  return 0;
}
开发者ID:Ankso,项目名称:node,代码行数:47,代码来源:signal.c

示例5: options_set_number

struct options_entry *
options_set_number(struct options *oo, const char *name, long long value)
{
	struct options_entry	*o;

	if ((o = options_find1(oo, name)) == NULL) {
		o = xmalloc(sizeof *o);
		o->name = xstrdup(name);
		RB_INSERT(options_tree, &oo->tree, o);
		memcpy(&o->style, &grid_default_cell, sizeof o->style);
	} else if (o->type == OPTIONS_STRING)
		free(o->str);

	o->type = OPTIONS_NUMBER;
	o->num = value;
	return (o);
}
开发者ID:20400992,项目名称:tmux,代码行数:17,代码来源:options.c

示例6: mode_key_init_trees

void
mode_key_init_trees(void)
{
	const struct mode_key_table	*mtab;
	const struct mode_key_entry	*ment;
	struct mode_key_binding		*mbind;

	for (mtab = mode_key_tables; mtab->name != NULL; mtab++) {
		RB_INIT(mtab->tree);
		for (ment = mtab->table; ment->key != KEYC_NONE; ment++) {
			mbind = xmalloc(sizeof *mbind);
			mbind->key = ment->key;
			mbind->cmd = ment->cmd;
			RB_INSERT(mode_key_tree, mtab->tree, mbind);
		}
	}
}
开发者ID:ThomasAdam,项目名称:tmux-obsd,代码行数:17,代码来源:mode-key.c

示例7: ramstat_decrement

static void
ramstat_decrement(const char *name, size_t val)
{
	struct ramstat_entry	*np, lk;

	log_trace(TRACE_STAT, "ramstat: decrement: %s", name);
	(void)strlcpy(lk.key, name, sizeof (lk.key));
	np = RB_FIND(stats_tree, &stats, &lk);
	if (np == NULL) {
		np = xcalloc(1, sizeof *np, "ramstat_decrement");
		(void)strlcpy(np->key, name, sizeof (np->key));
		RB_INSERT(stats_tree, &stats, np);
	}
	log_trace(TRACE_STAT, "ramstat: %s (%p): %zd -> %zd",
	    name, name, np->value.u.counter, np->value.u.counter - val);
	np->value.u.counter -= val;
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:17,代码来源:stat_ramstat.c

示例8: ct_extract_insert_entry

void
ct_extract_insert_entry(struct ct_pending_files *head, struct fnode *fnode)
{
	struct ct_pending_file	*cpf;

	CNDBG(CT_LOG_FILE, "%s: inserting %s", __func__, fnode->fn_fullname);
	cpf = e_calloc(1, sizeof(*cpf));
	cpf->cpf_name = e_strdup(fnode->fn_fullname);
	cpf->cpf_uid = fnode->fn_uid;
	cpf->cpf_gid = fnode->fn_gid;
	cpf->cpf_mode = fnode->fn_mode;
	cpf->cpf_mtime = fnode->fn_mtime;
	cpf->cpf_atime = fnode->fn_atime;

	TAILQ_INIT(&cpf->cpf_links);
	RB_INSERT(ct_pending_files, head, cpf);
}
开发者ID:Bluerise,项目名称:cyphertite,代码行数:17,代码来源:ct_ops.c

示例9: uv_timer_start

int uv_timer_start(uv_timer_t* handle,
                   uv_timer_cb cb,
                   uint64_t timeout,
                   uint64_t repeat) {
  if (uv__is_active(handle))
    uv_timer_stop(handle);

  handle->timer_cb = cb;
  handle->timeout = handle->loop->time + timeout;
  handle->repeat = repeat;
  /* start_id is the second index to be compared in uv__timer_cmp() */
  handle->start_id = handle->loop->timer_counter++;

  RB_INSERT(uv__timers, &handle->loop->timer_handles, handle);
  uv__handle_start(handle);

  return 0;
}
开发者ID:AllSeeingEye,项目名称:node,代码行数:18,代码来源:timer.c

示例10: emm_proc_common_initialize

/****************************************************************************
 **                                                                        **
 ** Name:    emm_proc_common_initialize()                              **
 **                                                                        **
 ** Description: Initialize EMM procedure callback functions executed for  **
 **      the UE with the given identifier                          **
 **                                                                        **
 ** Inputs:  ueid:      UE lower layer identifier                  **
 **      success:   EMM procedure executed upon successful EMM **
 **             common procedure completion                **
 **      reject:    EMM procedure executed if the EMM common   **
 **             procedure failed or is rejected            **
 **      failure:   EMM procedure executed upon transmission   **
 **             failure reported by lower layer            **
 **      abort:     EMM common procedure executed when the on- **
 **             going EMM procedure is aborted             **
 **      args:      EMM common procedure argument parameters   **
 **      Others:    None                                       **
 **                                                                        **
 ** Outputs:     None                                                      **
 **      Return:    RETURNok, RETURNerror                      **
 **      Others:    _emm_common_data                           **
 **                                                                        **
 ***************************************************************************/
int
emm_proc_common_initialize (
  unsigned int ueid,
  emm_common_success_callback_t _success,
  emm_common_reject_callback_t _reject,
  emm_common_failure_callback_t _failure,
  emm_common_abort_callback_t _abort,
  void *args)
{
  struct emm_common_data_s               *emm_common_data_ctx = NULL;

  LOG_FUNC_IN;
#if NAS_BUILT_IN_EPC
  assert (ueid > 0);
  emm_common_data_ctx = emm_common_data_context_get (&emm_common_data_head, ueid);
#else
  assert (ueid < EMM_DATA_NB_UE_MAX);
#endif

  if (emm_common_data_ctx == NULL) {
    emm_common_data_ctx = (emm_common_data_t *) malloc (sizeof (emm_common_data_t));
    emm_common_data_ctx->ueid = ueid;
#if NAS_BUILT_IN_EPC
    RB_INSERT (emm_common_data_map, &emm_common_data_head.emm_common_data_root, emm_common_data_ctx);
#endif

    if (emm_common_data_ctx) {
      emm_common_data_ctx->ref_count = 0;
    }
  }

  if (emm_common_data_ctx) {
    emm_common_data_ctx->ref_count += 1;
    emm_common_data_ctx->success = _success;
    emm_common_data_ctx->reject = _reject;
    emm_common_data_ctx->failure = _failure;
    emm_common_data_ctx->abort = _abort;
    emm_common_data_ctx->args = args;
    LOG_FUNC_RETURN (RETURNok);
  }

  LOG_FUNC_RETURN (RETURNerror);
}
开发者ID:debashish216,项目名称:lte-testbed-news,代码行数:67,代码来源:EmmCommon.c

示例11: uv_timer_start

int uv_timer_start(uv_timer_t* handle,
                   uv_timer_cb cb,
                   int64_t timeout,
                   int64_t repeat) {
  assert(timeout >= 0);
  assert(repeat >= 0);

  if (uv__is_active(handle))
    uv_timer_stop(handle);

  handle->timer_cb = cb;
  handle->timeout = handle->loop->time + timeout;
  handle->repeat = repeat;

  RB_INSERT(uv__timers, &handle->loop->timer_handles, handle);
  uv__handle_start(handle);

  return 0;
}
开发者ID:2hanson,项目名称:node,代码行数:19,代码来源:timer.c

示例12: add_tree_node

static void
add_tree_node(tcpr_tree_t *newnode)
{
    tcpr_tree_t *node;

    /* try to find a simular entry in the tree */
    node = RB_FIND(tcpr_data_tree_s, &treeroot, newnode);

    dbgx(3, "%s", tree_printnode("add_tree", node));

    /* new entry required */
    if (node == NULL) {
        /* increment counters */
        if (newnode->type == DIR_SERVER) {
            newnode->server_cnt++;
        }
        else if (newnode->type == DIR_CLIENT) {
            newnode->client_cnt++;
        }
        /* insert it in */
        RB_INSERT(tcpr_data_tree_s, &treeroot, newnode);

    }
    else {
        /* we found something, so update it */
        dbgx(2, "   node: %p\nnewnode: %p", node, newnode);
        dbgx(3, "%s", tree_printnode("update node", node));
        /* increment counter */
        if (newnode->type == DIR_SERVER) {
            node->server_cnt++;
        }
        else if (newnode->type == DIR_CLIENT) {
            /* temp debug code */
            node->client_cnt++;
        }
                    
        /* didn't insert it, so free it */
        safe_free(newnode);
    }

    dbg(2, "------- START NEXT -------");
    dbgx(3, "%s", tree_print(&treeroot));
}
开发者ID:Mipam,项目名称:tcpreplay,代码行数:43,代码来源:tree.c

示例13: notify_sel

void notify_sel(int slot, const dm_selector sel,
		const DM_VALUE value, enum notify_type type)
{
#if defined(SDEBUG)
        char b1[MAX_PARAM_NAME_LEN];
#endif
	struct notify_item si;

	uint32_t ntfy = value.notify;

	if (ntfy == 0)
		/* not notify's at all */
		return;

	debug("(): %s, %08x ... %d", dm_sel2name(sel, b1, sizeof(b1)), ntfy, slot);

	dm_selcpy(si.sb, sel);

	for (int i = 0; i < 16; i++) {
		/* skip notify for slot */
		if (i != slot) {
			int level = ntfy & 0x0003;
			if (level) {
				struct notify_item *item;
				item = RB_FIND(notify_queue, &slots[i].queue, &si);
				if (!item) {
					item = malloc(sizeof(struct notify_item));
					if (!item)
						continue;
					dm_selcpy(item->sb, sel);

					RB_INSERT(notify_queue, &slots[i].queue, item);
					notify_pending = 1;
				}
				item->level = level;
				item->type = type;
				item->value = value;
			}
		}
		ntfy >>= 2;
	}
}
开发者ID:KanjiMonster,项目名称:mand,代码行数:42,代码来源:dm_notify.c

示例14: flexran_agent_create_channel

int flexran_agent_create_channel(void *channel_info,
				 int (*msg_send)(void *data, int size, int priority, void *channel_info),
				 int (*msg_recv)(void **data, int *size, int *priority, void *channel_info),
				 void (*release)(flexran_agent_channel_t *channel)) {
  
  int channel_id = ++flexran_agent_channel_id;
  flexran_agent_channel_t *channel = (flexran_agent_channel_t *) malloc(sizeof(flexran_agent_channel_t));
  channel->channel_id = channel_id;
  channel->channel_info = channel_info;
  channel->msg_send = msg_send;
  channel->msg_recv = msg_recv;
  channel->release = release;
  
  /*element should be a real pointer*/
  RB_INSERT(flexran_agent_channel_map, &channel_instance.flexran_agent_head, channel); 
  
  LOG_I(FLEXRAN_AGENT,"Created a new channel with id 0x%lx\n", channel->channel_id);
 
  return channel_id; 
}
开发者ID:ShibinMathew36,项目名称:OAI-step,代码行数:20,代码来源:flexran_agent_net_comm.c

示例15: drm_adddraw

int drm_adddraw(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
	struct drm_draw *draw = data;
	struct bsd_drm_drawable_info *info;

	info = malloc(sizeof(struct bsd_drm_drawable_info), DRM_MEM_DRAWABLE,
	    M_NOWAIT | M_ZERO);
	if (info == NULL)
		return ENOMEM;

	info->handle = alloc_unr(dev->drw_unrhdr);
	DRM_SPINLOCK(&dev->drw_lock);
	RB_INSERT(drawable_tree, &dev->drw_head, info);
	draw->handle = info->handle;
	DRM_SPINUNLOCK(&dev->drw_lock);

	DRM_DEBUG("%d\n", draw->handle);

	return 0;
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:20,代码来源:drm_drawable.c


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