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


C++ LL_APPEND函数代码示例

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


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

示例1: gnrc_pktbuf_add

static gnrc_pktsnip_t *_build_ipv6_packet(const ipv6_addr_t *src,
                                          const ipv6_addr_t *dst, uint8_t nh,
                                          void *data, size_t data_len,
                                          uint16_t netif)
{
    gnrc_pktsnip_t *netif_hdr, *ipv6, *payload;
    ipv6_hdr_t *ipv6_hdr;

    if ((netif > INT16_MAX) || (data_len > UINT16_MAX)) {
        return NULL;
    }

    payload = gnrc_pktbuf_add(NULL, data, data_len, GNRC_NETTYPE_UNDEF);
    if (payload == NULL) {
        return NULL;
    }
    ipv6 = gnrc_ipv6_hdr_build(NULL, src, dst);
    if (ipv6 == NULL) {
        return NULL;
    }
    ipv6_hdr = ipv6->data;
    ipv6_hdr->len = byteorder_htons((uint16_t)payload->size);
    ipv6_hdr->nh = nh;
    ipv6_hdr->hl = 64;
    LL_APPEND(payload, ipv6);
    netif_hdr = gnrc_netif_hdr_build(NULL, 0, NULL, 0);
    if (netif_hdr == NULL) {
        return NULL;
    }
    ((gnrc_netif_hdr_t *)netif_hdr->data)->if_pid = (kernel_pid_t)netif;
    LL_APPEND(payload, netif_hdr);
    return payload;
}
开发者ID:LucaZulberti,项目名称:RIOT,代码行数:33,代码来源:stack.c

示例2: main

int main() {
    int i;
    el els[10], *e, *tmp, *tmp2;
    for(i=0;i<10;i++) els[i].id='a'+i;

    /* test LL macros */
    printf("LL macros\n");
    LL_APPEND(head,&els[0]);
    LL_APPEND(head,&els[1]);
    LL_APPEND(head,&els[2]);
    LL_FOREACH(head,e)
        printf("%c ", e->id);
    printf("\n");
    LL_SEARCH_SCALAR(head, e, id, 'b');
    if (e) printf("search scalar found b\n");
    LL_SEARCH(head, e, &els[0], eltcmp);
    if (e) printf("search found %c\n",e->id);
    LL_FOREACH_SAFE(head,e,tmp) LL_DELETE(head,e);

    printf("\n");

    /* test DL macros */
    printf("DL macros\n");
    DL_APPEND(head,&els[0]);
    DL_APPEND(head,&els[1]);
    DL_APPEND(head,&els[2]);
    DL_FOREACH(head,e)
        printf("%c ", e->id);
    printf("\n");
    DL_SEARCH_SCALAR(head, e, id, 'b');
    if (e) printf("search scalar found b\n");
    DL_SEARCH(head, e, &els[0], eltcmp);
    if (e) printf("search found %c\n",e->id);
    DL_FOREACH_SAFE(head,e,tmp) DL_DELETE(head,e);
    printf("\n");

    /* test CDL macros */
    printf("CDL macros\n");
    CDL_PREPEND(head,&els[0]);
    CDL_PREPEND(head,&els[1]);
    CDL_PREPEND(head,&els[2]);
    CDL_FOREACH(head,e)
        printf("%c ", e->id);
    printf("\n");
    CDL_SEARCH_SCALAR(head, e, id, 'b');
    if (e) printf("search scalar found b\n");
    CDL_SEARCH(head, e, &els[0], eltcmp);
    if (e) printf("search found %c\n",e->id);
    CDL_FOREACH_SAFE(head,e,tmp,tmp2) CDL_DELETE(head,e);


    return 0;
}
开发者ID:bitfixer,项目名称:bitfixer,代码行数:53,代码来源:test42.c

示例3: db_change_parent

int
db_change_parent(Objid oid, Objid parent)
{
    Objid old_parent;

    if (!dbpriv_check_properties_for_chparent(oid, parent))
	return 0;

    if (objects[oid]->child == NOTHING && objects[oid]->verbdefs == NULL) {
	/* Since this object has no children and no verbs, we know that it
	   can't have had any part in affecting verb lookup, since we use first
	   parent with verbs as a key in the verb lookup cache. */
	/* The "no kids" rule is necessary because potentially one of the kids
	   could have verbs on it--and that kid could have cache entries for
	   THIS object's parentage. */
	/* In any case, don't clear the cache. */
	;
    } else {
	db_priv_affected_callable_verb_lookup();
    }

    old_parent = objects[oid]->parent;

    if (old_parent != NOTHING)
	LL_REMOVE(old_parent, child, oid, sibling);

    if (parent != NOTHING)
	LL_APPEND(parent, child, oid, sibling);

    objects[oid]->parent = parent;
    dbpriv_fix_properties_after_chparent(oid, old_parent);

    return 1;
}
开发者ID:welterde,项目名称:NuMOO,代码行数:34,代码来源:db_objects.c

示例4: nitro_async_schedule

void nitro_async_schedule(nitro_async_t *a) {
    pthread_mutex_lock(&the_runtime->l_async);
    LL_APPEND(the_runtime->async_queue, a);
    pthread_mutex_unlock(&the_runtime->l_async);
    ev_async_send(the_runtime->the_loop,
                  &the_runtime->thread_wake);
}
开发者ID:bumptech,项目名称:nitro,代码行数:7,代码来源:async.c

示例5: gethttpmirrors

static void
gethttpmirrors(struct pkg_repo *repo, const char *url) {
	FILE *f;
	char *line = NULL;
	size_t linecap = 0;
	ssize_t linelen;
	struct http_mirror *m;
	struct url *u;

	if ((f = fetchGetURL(url, "")) == NULL)
		return;

	while ((linelen = getline(&line, &linecap, f)) > 0) {
		if (strncmp(line, "URL:", 4) == 0) {
			/* trim '\n' */
			if (line[linelen - 1] == '\n')
				line[linelen - 1 ] = '\0';

			line += 4;
			while (isspace(*line)) {
				line++;
			}
			if (*line == '\0')
				continue;

			if ((u = fetchParseURL(line)) != NULL) {
				m = malloc(sizeof(struct http_mirror));
				m->url = u;
				LL_APPEND(repo->http, m);
			}
		}
	}
	fclose(f);
	return;
}
开发者ID:O2Graphics,项目名称:pkg,代码行数:35,代码来源:fetch.c

示例6: gnrc_sixlowpan_frag_rbuf_dispatch_when_complete

void gnrc_sixlowpan_frag_rbuf_dispatch_when_complete(gnrc_sixlowpan_rbuf_t *rbuf,
                                                     gnrc_netif_hdr_t *netif_hdr)
{
    assert(rbuf);
    assert(netif_hdr);
    if (rbuf->current_size == rbuf->pkt->size) {
        gnrc_pktsnip_t *netif = gnrc_netif_hdr_build(rbuf->src,
                                                     rbuf->src_len,
                                                     rbuf->dst,
                                                     rbuf->dst_len);

        if (netif == NULL) {
            DEBUG("6lo rbuf: error allocating netif header\n");
            gnrc_pktbuf_release(rbuf->pkt);
            gnrc_sixlowpan_frag_rbuf_remove(rbuf);
            return;
        }

        /* copy the transmit information of the latest fragment into the newly
         * created header to have some link_layer information. The link_layer
         * info of the previous fragments is discarded.
         */
        gnrc_netif_hdr_t *new_netif_hdr = netif->data;
        new_netif_hdr->if_pid = netif_hdr->if_pid;
        new_netif_hdr->flags = netif_hdr->flags;
        new_netif_hdr->lqi = netif_hdr->lqi;
        new_netif_hdr->rssi = netif_hdr->rssi;
        LL_APPEND(rbuf->pkt, netif);
        gnrc_sixlowpan_dispatch_recv(rbuf->pkt, NULL, 0);
        gnrc_sixlowpan_frag_rbuf_remove(rbuf);
    }
}
开发者ID:kbumsik,项目名称:RIOT,代码行数:32,代码来源:gnrc_sixlowpan_frag.c

示例7: loadInterfaces

static Interface* loadInterfaces(Env* env, Class* clazz) {
    ClassInfoHeader* header = lookupClassInfo(env, clazz->name, 
        !clazz->classLoader || !clazz->classLoader->parent ? _bcBootClassesHash : _bcClassesHash);
    if (!header) return NULL;

    ClassInfo ci;
    jint i;
    void* p = header;
    readClassInfo(&p, &ci);

    Interface* first = NULL;
    for (i = 0; i < ci.interfaceCount; i++) {
        const char* interfaceName = readInterfaceName(&p);
        Class* interfaceClass = rvmFindClassUsingLoader(env, interfaceName, clazz->classLoader);
        if (!interfaceClass) goto error;
        Interface* interf = rvmAllocateInterface(env, interfaceClass);
        if (!interf) goto error;
        LL_APPEND(first, interf); // Interfaces has to be in the correct order so we need to use the slower LL_APPEND
    }
    return first;
error:
    while (first) {
        Interface* next = first->next;
        rvmFreeMemoryUncollectable(env, first);
        first = next;
    }
    return NULL;
}
开发者ID:SinoJerk,项目名称:robovm,代码行数:28,代码来源:bc.c

示例8: newControlledLed

ControlledLeds newControlledLed(Led led) {
    struct LedGroup group = (struct LedGroup){ &led, 1 };
    return newControlledLedGroup(&group);
}

ControlledLeds newControlledLedGroup(LedGroup group) {
    if (group == NULL) return Invalid(ControlledLeds);
    _ControlledLeds leds = kalloc(sizeof(struct _ControlledLeds));
    if (!leds) return Invalid(ControlledLeds);
    LedList *underlying = addNewLedsToList(group);
    if (!underlying) {
        free(leds);
        return Invalid(ControlledLeds);
    }
    leds->mask = 0;
    leds->leds = underlying;
    leds->count = group->count;
    leds->next = NULL;
    ControlledLeds result = As(ControlledLeds, leds);
    controlLeds(result, LedsDisabled);
    LL_APPEND(controlled_leds, leds);
    return result;
}

static void cleanUnderlyingLeds(ControlledLeds leds) {
    LedList elem = NULL, tmp = NULL;
    LL_FOREACH_SAFE(underlying_leds, elem, tmp) {
        for (int i = 0; i < LEDS->count; i++) {
            if (elem == LEDS->leds[i]) {
                reduceRefcount(elem);
            }
        }
    }
}
开发者ID:antongulenko,项目名称:TankOS,代码行数:34,代码来源:led_control.c

示例9: kalloc

static LedList *addNewLedsToList(LedGroup group) {
    for (uint8_t i = 0; i < group->count; i++) {
        if (!ledValid(group->leds[i]))
            return NULL;
    }
    LedList *list = kalloc(group->count * sizeof(LedList));
    if (!list) return NULL;
    for (int i = 0; i < group->count; i++) {
        Led led = group->leds[i];
        LedList existing = NULL;
        LL_FOREACH(underlying_leds, existing) {
            if (Equal(existing->led, led)) break;
        }
        if (existing == NULL) {
            existing = kalloc(sizeof(struct LedList));
            if (!existing) {
                // Cleanup all leds added so far...
                for (int j = 0; j < i; j++) {
                    reduceRefcount(list[j]);
                }
                free(list);
                return NULL;
            }
            existing->led = led;
            existing->next = NULL;
            existing->enabled = FALSE;
            existing->references = 0;
            LL_APPEND(underlying_leds, existing);
        }
        existing->references++;
        list[i] = existing;
    }
    return list;
}
开发者ID:antongulenko,项目名称:TankOS,代码行数:34,代码来源:led_control.c

示例10: AddServerResponse

/**
 * Add a server response to the server response list
 *
 * @param response initialized server response that is created by this function
 * @param requestHandle - handle of the response
 *
 * @return
 *     OCStackResult
 */
static OCStackResult AddServerResponse (OCServerResponse ** response, OCRequestHandle requestHandle)
{
    if (!response)
    {
        return OC_STACK_INVALID_PARAM;
    }

    OCServerResponse * serverResponse = NULL;

    serverResponse = (OCServerResponse *) OICCalloc(1, sizeof(OCServerResponse));
    VERIFY_NON_NULL(serverResponse);

    serverResponse->payload = NULL;

    serverResponse->requestHandle = requestHandle;

    *response = serverResponse;
    OIC_LOG(INFO, TAG, "Server Response Added!!");
    LL_APPEND (serverResponseList, serverResponse);
    return OC_STACK_OK;

exit:
    if (serverResponse)
    {
        OICFree(serverResponse);
        serverResponse = NULL;
    }
    *response = NULL;
    return OC_STACK_NO_MEMORY;
}
开发者ID:Frank-KunLi,项目名称:iotivity,代码行数:39,代码来源:ocserverrequest.c

示例11: pthread_scheduler_push_kernel

void pthread_scheduler_push_kernel (kernel_run_command *run_cmd)
{
  PTHREAD_LOCK (&scheduler.wq_lock, NULL);
  LL_APPEND (scheduler.kernel_queue, run_cmd);
  pthread_cond_broadcast (&scheduler.wake_pool);
  PTHREAD_UNLOCK (&scheduler.wq_lock);
}
开发者ID:dsandersimgtec,项目名称:pocl,代码行数:7,代码来源:pthread_scheduler.c

示例12: AddPlugin

OCStackResult AddPlugin (PIPluginBase * plugin)
{
    if (!plugin)
    {
        return OC_STACK_INVALID_PARAM;
    }

    LL_APPEND(pluginList, plugin);
    return OC_STACK_OK;
}
开发者ID:Lyoncore,项目名称:iotivity-demo-uc15,代码行数:10,代码来源:pluginlist.c

示例13: rpcfg_string

static int
rpcfg_string(void *data, const unsigned char *s, size_t len)
{
	struct rp_json_ctx *ctx = (struct rp_json_ctx *)data;

	switch (ctx->state) {
	case ROOT_CONFIG_IDENTITY_NICKS_ITEMS:
	{
		rp_str_list_t *l = rp_palloc(ctx->pool, sizeof(*l));
		rpcfg_mkstr(ctx->pool, &l->str, (const char *)s, len);
		LL_APPEND(ctx->cfg->identity.nicks, l);
		return 1;
	}
	case ROOT_CONFIG_IDENTITY_NAME:
		rpcfg_mkstr(ctx->pool, &ctx->cfg->identity.name, (const char *)s, len);
		ctx->state = ROOT_CONFIG_IDENTITY;
		return 1;
	case ROOT_CONFIG_IDENTITY_LOGIN:
		rpcfg_mkstr(ctx->pool, &ctx->cfg->identity.login, (const char *)s, len);
		ctx->state = ROOT_CONFIG_IDENTITY;
		return 1;
		break;
	case ROOT_CONFIG_SERVERS_ITEMS_HOST:
		rpcfg_mkstr(ctx->pool, &ctx->server->host, (const char *)s, len);
		ctx->state = ROOT_CONFIG_SERVERS_ITEMS;
		return 1;
	case ROOT_CONFIG_SERVERS_ITEMS_PORT:
		rpcfg_mkstr(ctx->pool, &ctx->server->port, (const char *)s, len);
		ctx->state = ROOT_CONFIG_SERVERS_ITEMS;
		return 1;
	case ROOT_CONFIG_CHANNELS_ITEMS:
		ctx->channel = rp_pcalloc(ctx->pool, sizeof(*ctx->channel));
		ctx->channel->key.len = 0;
		rpcfg_mkstr(ctx->pool, &ctx->channel->name, (const char *)s, len);
		LL_APPEND(ctx->cfg->channels, ctx->channel);
		return 1;
	default:
		return 0;
	}

	return 1;
}
开发者ID:skroll,项目名称:rpbot,代码行数:42,代码来源:rp_config.c

示例14: pubsub_url_cb

int pubsub_url_cb(char *value)
{
    struct pubsub_url *ps_url;
    ps_url = malloc(sizeof(struct pubsub_url));
    ps_url->address = strdup(value);
    ps_url->id = num_pubsub_urls;
    LL_APPEND(pubsub_urls, ps_url);
    num_pubsub_urls++;
    
    return 1;
}
开发者ID:LevinLin,项目名称:simplehttp,代码行数:11,代码来源:ps_to_http.c

示例15: load_rules

/* Loads a list of allowed hostnames and ports from file. Format is hostname:port*/
void load_rules()
{
    char *ahost=NULL;
    int aport=0;
    char line[100 + 1] = "";
    FILE *file = NULL;
    rule *rule_obj = NULL;
    int valid_rules = 0;

    file = fopen(rules_file, "r");
    
    if (file == NULL) {
        log_printf(L_WARNING, "Could not open rules file (%s)\n", rules_file);
        return;
    }
    
    while (fgets(line, sizeof(line), file)) {
        /* allow comments & white lines */
        if (line[0]=='#'||line[0]=='\n') {
            continue;
        }
        if (parse_pipe_port_forward(line, &ahost, &aport) >= 0) {
            if (aport > 0 && aport < 65535) {

                rule_obj = (rule *)calloc(sizeof(rule), 1);
                if(!rule_obj)
                {
                    log_printf(L_ERROR, "Could not allocate memory for rule");
                    exit(1);
                }

                rule_obj->port = aport;
                rule_obj->host = strdup(ahost);

                LL_APPEND(rules, rule_obj);
                valid_rules++;
            } else {
                log_printf(L_WARNING, "Invalid port in line: %s\n", line);
            }
        } else {
            log_printf(L_WARNING, "Could not parse line: %s\n", line);
        }
    }
    fclose(file);
    
    /* save valid rules in global variable */
    nrules = valid_rules;
    
    log_printf(L_INFO, "Loaded %d rules\n", nrules);
    if (nrules==0 && rules_policy != NONE){
        log_printf(L_WARNING, "No rules loaded! NO CONNECTIONS WILL BE ALLOWED!\n");
    }
}
开发者ID:gjedeer,项目名称:tuntox,代码行数:54,代码来源:main.c


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