您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ HASH_ADD_KEYPTR函数代码示例

51自学网 2021-06-01 21:22:20
  C++
这篇教程C++ HASH_ADD_KEYPTR函数代码示例写得很实用,希望能帮到您。

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

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

示例1: springfield_set_i

static void springfield_set_i(springfield_t *r, char *key, uint8_t *val, uint32_t vlen) {    int klen = strlen(key) + 1;    assert(klen < MAX_KLEN);    assert(vlen < MAX_VLEN);    uint32_t step = HEADER_SIZE + klen + vlen;    springfield_header_v1 h = {0};    h.klen = klen;    h.vlen = vlen;    h.version = 1;    if (r->in_rewrite) {        springfield_key_t *kobj = NULL;        HASH_FIND(hh, r->rewrite_keys, key, klen, kobj);        if (!kobj) {            kobj = calloc(1, sizeof(springfield_key_t));            kobj->key = strdup(key);            HASH_ADD_KEYPTR(hh, r->rewrite_keys, key, klen, kobj);        }    }    if (r->eof + step > r->mmap_alloc) {        msync(r->map, r->mmap_alloc, MS_SYNC);        int s = munmap(r->map, r->mmap_alloc);        assert(!s);        uint64_t new_size = r->mmap_alloc + ((r->eof + step) * 2);        r->mmap_alloc = new_size;        s = ftruncate(r->mapfd, (off_t)r->mmap_alloc);        assert(!s);        r->map = (uint8_t *)mmap(            NULL, r->mmap_alloc, PROT_READ | PROT_WRITE, MAP_SHARED, r->mapfd, 0);        /* TODO mremap() on linux */        s = madvise(r->map, r->mmap_alloc, MADV_RANDOM);        assert(!s);    }    h.last = springfield_index_keyval(r, key, r->eof);    uint8_t *p = &r->map[r->eof];    springfield_header_v1 *ph = (springfield_header_v1 *)p;    *ph = h;    memmove(p + HEADER_SIZE, key, klen);    if (vlen)        memmove(p + HEADER_SIZE + klen, val, vlen);    ph->crc = crc32(0, p + 4, HEADER_SIZE_MINUS_CRC + klen + vlen);    r->eof += step;}
开发者ID:jamwt,项目名称:springfield,代码行数:51,


示例2: symbol_insert

void symbol_insert(const char* name, LLVMValueRef val, int isArg){  struct symbol_info *si;  if (head==NULL)    return;  si = (struct symbol_info*) malloc(sizeof(struct symbol_info));  si->name = (char*)name;  si->isArg = isArg;  si->val = val;  HASH_ADD_KEYPTR( hh, head->map, name, strlen(name), si );}
开发者ID:FeifeiWang7,项目名称:ECE566,代码行数:14,


示例3: listen_device_if_not_present

static void listen_device_if_not_present(const char *devnode){	struct hash_element *same_elem = NULL;	HASH_FIND_STR(fdhash, devnode, same_elem);	if (same_elem) {		return;	}	struct hash_element *elem = hash_element_from_devnode(devnode);	if (!elem) {		return;	}	HASH_ADD_KEYPTR(hh, fdhash, elem->devnode, strlen(elem->devnode), elem);	FD_SET(elem->fd, &evdevfds);}
开发者ID:gentoo-root,项目名称:jacklistener,代码行数:14,


示例4: olsr_db_ns_gcneigh

olsr_db_ns_tuple_t* olsr_db_ns_gcneigh(uint8_t neighbor_main_addr[ETH_ALEN]) {    olsr_db_ns_tuple_t* tuple;    HASH_FIND(hh, neighbor_set, neighbor_main_addr, ETH_ALEN, tuple);    if(tuple == NULL) {        if(ntuple_create(&tuple, neighbor_main_addr) == false) {            return false;        }        HASH_ADD_KEYPTR(hh, neighbor_set, tuple->neighbor_main_addr, ETH_ALEN, tuple);    }    return tuple;}
开发者ID:Dekue,项目名称:des-routing-algorithms,代码行数:14,


示例5: fcitx_handler_table_key_struct

static FcitxHandlerKey*fcitx_handler_table_key_struct(FcitxHandlerTable *table, size_t keysize,                               const void *key, boolean create){    FcitxHandlerKey *key_struct = NULL;    HASH_FIND(hh, table->keys, key, keysize, key_struct);    if (key_struct || !create)        return key_struct;    key_struct = malloc(sizeof(FcitxHandlerKey) + keysize);    key_struct->first = key_struct->last = FCITX_OBJECT_POOL_INVALID_ID;    memcpy(key_struct + 1, key, keysize);    key = key_struct + 1;    HASH_ADD_KEYPTR(hh, table->keys, key, keysize, key_struct);    return key_struct;}
开发者ID:adaptee,项目名称:fcitx,代码行数:15,


示例6: frequencies_hash_to_bins

struct document_frequencies_hash* frequencies_hash_to_bins(struct score_hash *scores) {	struct score_hash *s;	struct document_frequencies_hash *tmp, *bins_hash = NULL;	int bin_index = 0;	HASH_SORT(scores, ascending_score_sort);	for(s=scores; s != NULL; s = s->hh.next) {		if (s->score >= 10.5) { break; } // Filter >4 frequent words		tmp = (struct document_frequencies_hash*)malloc(sizeof(struct document_frequencies_hash));		tmp->word = strdup(s->word);		tmp->count = ++bin_index;		HASH_ADD_KEYPTR( hh, bins_hash, tmp->word, strlen(tmp->word), tmp );	}	fprintf(stderr, "Total bins: %d/n",bin_index);	return bins_hash;}
开发者ID:KWARC,项目名称:deprecated-LLaMaPUn,代码行数:15,


示例7: pkg_update_increment_item_new

static voidpkg_update_increment_item_new(struct pkg_increment_task_item **head, const char *origin,		const char *digest, long offset){	struct pkg_increment_task_item *item;	item = calloc(1, sizeof(struct pkg_increment_task_item));	item->origin = strdup(origin);	if (digest == NULL)		digest = "";	item->digest = strdup(digest);	item->offset = offset;	HASH_ADD_KEYPTR(hh, *head, item->origin, strlen(item->origin), item);}
开发者ID:renchap,项目名称:pkg,代码行数:15,


示例8: getTextureID

Texture* getTextureID(char* path)  {    Texture *s;    HASH_FIND_STR( pathToTexTable, path, s );  /* s: output pointer */    if(s == NULL)  {        s = (Texture*)malloc(sizeof(Texture));        s->path = (char*)malloc(strlen(path)*sizeof(char));        strcpy(s->path, path);        s->textureID = ilutGLLoadImage(path);        s->width = ilGetInteger(IL_IMAGE_WIDTH);        s->height = ilGetInteger(IL_IMAGE_HEIGHT);        HASH_ADD_KEYPTR( hh, pathToTexTable, s->path, strlen(s->path), s );    }    return s;}
开发者ID:catdawg,项目名称:Ez2DS,代码行数:15,


示例9: load_module

Module load_module(char *mn) {  char *modname = malloc(sizeof(char)*768);  snprintf(modname, 767, "%s/%s.so", DPATH "/modules", mn);  int (*mod_init)();  void *modhand;  struct loaded_module *mod = malloc(sizeof(struct loaded_module));  modhand = mod->hand = dlopen(modname, RTLD_LAZY);  mod->name = strdup(mn);  if (modhand == NULL) exit(64);  mod_init = (int (*)())dlsym(modhand, "mod_init");  if (mod_init) (*mod_init)();  else exit(65);  HASH_ADD_KEYPTR(hh, mods, mod->name, strlen(mod->name), mod);  return mod;};
开发者ID:asterIRC,项目名称:troutfin,代码行数:15,


示例10: pkg_repo_overwrite

static voidpkg_repo_overwrite(struct pkg_repo *r, const char *name, const char *url,    const char *type){	free(r->name);	r->name = strdup(name);	if (url != NULL) {		free(r->url);		r->url = strdup(url);	}	r->ops = pkg_repo_find_type(type);	HASH_DEL(repos, r);	HASH_ADD_KEYPTR(hh, repos, r->name, strlen(r->name), r);}
开发者ID:dumbbell,项目名称:pkg,代码行数:15,


示例11: LoadPuncDict

/** * 加载标点词典 * @param void * @return void * @note 文件中数据的格式为: 对应的英文符号 中文标点 <中文标点> * 加载标点词典。标点词典定义了一组标点转换,如输入‘.’就直接转换成‘。’ */boolean LoadPuncDict(FcitxPuncState* puncState){    FcitxStringHashSet* puncfiles = FcitxXDGGetFiles("data", PUNC_DICT_FILENAME "." , NULL);    FcitxStringHashSet *curpuncfile = puncfiles;    FcitxPunc* punc;    while (curpuncfile) {        punc = LoadPuncFile(curpuncfile->name);        if (punc)            HASH_ADD_KEYPTR(hh, puncState->puncSet, punc->langCode, strlen(punc->langCode), punc);        curpuncfile = curpuncfile->hh.next;    }    fcitx_utils_free_string_hash_set(puncfiles);    return true;}
开发者ID:adaptee,项目名称:fcitx,代码行数:22,


示例12: LoadImage

SkinImage* LoadImage(FcitxSkin* sc, const char* name, boolean fallback){    cairo_surface_t *png = NULL;    SkinImage *image = NULL;    HASH_FIND_STR(sc->imageTable, name, image);    if (image != NULL) {        return image;    }    if (strlen(name) > 0 && strcmp(name , "NONE") != 0) {        char *skintype = strdup(*sc->skinType);        char *filename;        while (true) {            char* buf = NULL;            asprintf(&buf, "skin/%s", skintype);            FILE* fp = FcitxXDGGetFileWithPrefix(buf, name, "r", &filename);            free(buf);            Bool flagNoFile = (fp == NULL);            if (fp) {                fclose(fp);                png = cairo_image_surface_create_from_png(filename);                break;            }            if (flagNoFile && (!fallback || strcmp(skintype, "default") == 0)) {                png = NULL;                break;            }            free(filename);            free(skintype);            skintype = strdup("default");        }        free(filename);        free(skintype);    }    if (png != NULL) {        image = fcitx_utils_malloc0(sizeof(SkinImage));        image->name = strdup(name);        image->image = png;        HASH_ADD_KEYPTR(hh, sc->imageTable, image->name, strlen(image->name), image);        return image;    }    return NULL;}
开发者ID:niubenben,项目名称:fcitx,代码行数:48,


示例13: LoadImageWithText

SkinImage* LoadImageWithText(FcitxClassicUI* classicui, FcitxSkin* sc, const char* name, const char* text, int w, int h, boolean active){    if (!text || *text == '/0')        return NULL;    UnloadSingleImage(sc, name);    int len = fcitx_utf8_char_len(text);    if (len == 1 && text[len] && fcitx_utf8_char_len(text + len) == 1)        len = 2;    char* iconText = strndup(text, len);    FcitxLog(DEBUG, "%s", iconText);    cairo_surface_t* newsurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);    cairo_t* c = cairo_create(newsurface);    int min = w > h? h: w;    min = min * 0.8;    cairo_set_operator(c, CAIRO_OPERATOR_SOURCE);    cairo_set_source_rgba(c ,1, 1, 1, 0.0);    cairo_paint(c);    FcitxConfigColor color;    if (sc->skinMainBar.bUseCustomTextIconColor) {        if (active)            color = sc->skinMainBar.textIconColor[0];        else            color = sc->skinMainBar.textIconColor[1];    }    else        color = sc->skinFont.menuFontColor[1];    int textw, texth;    StringSizeStrict(iconText, classicui->font, min, false, &textw, &texth);    OutputString(c, iconText, classicui->font, min, false, (w - textw) * 0.5, 0, &color);    cairo_destroy(c);    SkinImage* image = fcitx_utils_malloc0(sizeof(SkinImage));    image->name = strdup(name);    image->image = newsurface;    image->textIcon = true;    HASH_ADD_KEYPTR(hh, sc->imageTable, image->name, strlen(image->name), image);    return image;}
开发者ID:areslp,项目名称:fcitx,代码行数:48,


示例14: loadFile

void loadFile( FILE *fp ) {   char buf[BUFFER_SIZE];  char *token;  const char *delimeter_chars = " /n";  frequencyListNode *ptr = NULL;  hashNode *curr_hashNode = (hashNode *)malloc( sizeof( hashNode ) );    while ( fgets( buf, BUFFER_SIZE, fp ) != NULL ) {    token = strtok( buf, delimeter_chars ); /* Stores the first <list> */    while ( token != NULL ) {      if ( strcmp( token, "<list>" ) == 0 ) {	token = strtok( NULL, delimeter_chars ); /* Stores the word in reference of the list */	curr_hashNode->word = (char *)malloc( sizeof( char ) * strlen( token ) + 1 );	strcpy( curr_hashNode->word, token );      }      else if ( strcmp( token, "</list>" ) == 0 ) {	/* Add the built list to the hashtable */	HASH_ADD_KEYPTR( hh, inverted_index, curr_hashNode->word, strlen( curr_hashNode->word ), curr_hashNode );	curr_hashNode = (hashNode *)malloc( sizeof( hashNode ) );      }      else {	ptr = (frequencyListNode *)malloc( sizeof( frequencyListNode ) );	ptr->file_path  = (char *)malloc( sizeof( char ) * strlen( token ) + 1 );	strcpy( ptr->file_path, token );	token = strtok( NULL, delimeter_chars ); /*Now holds the frequency of the word in previous file */	ptr->frequency = 0;	ptr->next = curr_hashNode->head;	curr_hashNode->head = ptr;      }      token = strtok( NULL, delimeter_chars );    }  }  free( curr_hashNode );}
开发者ID:kdharsee,项目名称:Search,代码行数:46,


示例15: pkg_repo_new

static struct pkg_repo *pkg_repo_new(const char *name, const char *url){	struct pkg_repo *r;	r = calloc(1, sizeof(struct pkg_repo));	r->type = REPO_BINARY_PKGS;	r->update = repo_update_binary_pkgs;	r->url = strdup(url);	r->signature_type = SIG_NONE;	r->mirror_type = NOMIRROR;	r->enable = true;	asprintf(&r->name, REPO_NAME_PREFIX"%s", name);	HASH_ADD_KEYPTR(hh, repos, r->name, strlen(r->name), r);	return (r);}
开发者ID:rottenbytes,项目名称:pkg,代码行数:17,


示例16: malloc

struct mod_function *add_cb(char *mod, char *cbn, char *cbsym) {  Module modu = NULL;  ModFunc modf = malloc(sizeof(struct mod_function));  HASH_FIND_STR(mods, mod, modu);  if (modu != NULL) {    int (*func)() = dlsym(modu->hand, cbsym);    if (!func) return NULL;    HASH_FIND_STR(modu->funcs, cbn, modf);    if (modf == NULL) {      modf->cb = cbn;      modf->func = &func;      HASH_ADD_KEYPTR(hh, modu->funcs, modf->cb, strlen(modf->cb), modf);      return modf;    }  }  return NULL;};
开发者ID:asterIRC,项目名称:troutfin,代码行数:17,


示例17: pkg_repo_new

static struct pkg_repo *pkg_repo_new(const char *name, const char *url, const char *type){	struct pkg_repo *r;	r = calloc(1, sizeof(struct pkg_repo));	r->ops = pkg_repo_find_type(type);	r->url = strdup(url);	r->signature_type = SIG_NONE;	r->mirror_type = NOMIRROR;	r->enable = true;	r->meta = pkg_repo_meta_default();	r->name = strdup(name);	HASH_ADD_KEYPTR(hh, repos, r->name, strlen(r->name), r);	return (r);}
开发者ID:dumbbell,项目名称:pkg,代码行数:17,


示例18: pkg_repo_binary_update_item_new

static voidpkg_repo_binary_update_item_new(struct pkg_increment_task_item **head, const char *origin,		const char *digest, long offset, long length, const char *checksum){	struct pkg_increment_task_item *item;	item = calloc(1, sizeof(struct pkg_increment_task_item));	item->origin = strdup(origin);	if (digest == NULL)		digest = "";	item->digest = strdup(digest);	item->offset = offset;	item->length = length;	if (checksum)		item->checksum = strdup(checksum);	HASH_ADD_KEYPTR(hh, *head, item->origin, strlen(item->origin), item);}
开发者ID:zxombie,项目名称:pkg,代码行数:18,


示例19: addInternedString

/** * Adds a string to the cache of interned string. The string must not already be * interned.  The internedStringsLock MUST be held when calling this function. */static jboolean addInternedString(Env* env, const char* s,  Object* string) {    CacheEntry* cacheEntry = allocateMemoryOfKind(env, sizeof(CacheEntry), cacheEntryGCKind);    if (!cacheEntry) {        return FALSE;    }    cacheEntry->key = s;    cacheEntry->string = string;    HASH_ADD_KEYPTR(hh, internedStrings, cacheEntry->key, strlen(cacheEntry->key), cacheEntry);    // prune the cache to MAX_CACHE_SIZE    if (HASH_COUNT(internedStrings) >= MAX_CACHE_SIZE) {        CacheEntry* tmpEntry;        HASH_ITER(hh, internedStrings, cacheEntry, tmpEntry) {            // prune the first entry (loop is based on insertion order so this deletes the oldest item)            HASH_DELETE(hh, internedStrings, cacheEntry);            break;        }
开发者ID:Custard7,项目名称:robovm,代码行数:22,


示例20: CloudPinyinAddToCache

CloudPinyinCache* CloudPinyinAddToCache(FcitxCloudPinyin* cloudpinyin, const char* pinyin, char* string){    CloudPinyinCache* cacheEntry = fcitx_utils_malloc0(sizeof(CloudPinyinCache));    cacheEntry->pinyin = strdup(pinyin);    cacheEntry->str = strdup(string);    HASH_ADD_KEYPTR(hh, cloudpinyin->cache, cacheEntry->pinyin, strlen(cacheEntry->pinyin), cacheEntry);    /* if there is too much cached, remove the first one, though LRU might be a better algorithm */    if (HASH_COUNT(cloudpinyin->cache) > MAX_CACHE_ENTRY)    {        CloudPinyinCache* head = cloudpinyin->cache;        HASH_DEL(cloudpinyin->cache, cloudpinyin->cache);        free(head->pinyin);        free(head->str);        free(head);    }    return cacheEntry;}
开发者ID:pkg-ime,项目名称:fcitx-cloudpinyin,代码行数:18,


示例21: kick_all_uniques

static void kick_all_uniques(struct node *node, struct node **uniq){    struct node *search;    while (HASH_COUNT(node->childs) == 1)    {        HASH_FIND_STR(*uniq, node->childs->word, search);        if (search == NULL)        {            search = malloc(sizeof(*search));            search->childs = NULL;            search->word = node->childs->word;            HASH_ADD_KEYPTR(hh, *uniq, search->word, strlen(search->word),                            search);        }        node = node->childs;    }}
开发者ID:JulienPalard,项目名称:Mine,代码行数:18,


示例22: LoadImage

LightUIImage* LoadImage(struct _FcitxLightUI* lightui, const char* name){    XImage* xpm = NULL, *mask = NULL;    LightUIImage *image = NULL;    HASH_FIND_STR(lightui->imageTable, name, image);    if (image != NULL)        return image;    if ( strlen(name) > 0 )    {        int i = 0;        while (builtInImage[i].name != NULL)        {            if (strcmp(builtInImage[i].name, name) == 0)            {                XpmAttributes   attrib;                attrib.valuemask = 0;                XpmCreateImageFromData (lightui->dpy, builtInImage[i].data , &xpm, &mask, &attrib);                break;            }            i ++;        }    }    if (xpm != NULL)    {        image = fcitx_malloc0(sizeof(LightUIImage));        image->name = strdup(name);        image->image = xpm;        image->mask = mask;        image->pixmask = XCreatePixmap(lightui->dpy, DefaultRootWindow(lightui->dpy), mask->width, mask->height, mask->depth);        GC gc = XCreateGC (lightui->dpy, image->pixmask, 0, NULL);        XPutImage(lightui->dpy, image->pixmask, gc, image->mask, 0, 0, 0, 0, mask->width, mask->height);        XFreeGC(lightui->dpy, gc);        HASH_ADD_KEYPTR(hh, lightui->imageTable, image->name, strlen(image->name), image);        return image;    }    return NULL;}
开发者ID:wengxt,项目名称:fcitx-ui-light,代码行数:42,


示例23: verify_application

static luarest_status verify_application(application** apps, const char* appName, UT_string* path){	int ret;	lua_State* ls = luaL_newstate();	application* app;		luaL_openlibs(ls);	luaopen_luarestlibs(ls);            ret = luaL_loadfile(ls, utstring_body(path));    if (ret != 0) {		printf("Couldn't load file: %s/n", lua_tostring(ls, -1));		lua_close(ls);		return(LUAREST_ERROR);    }	ret = lua_pcall(ls, 0, 0, 0);    if (ret != 0) {        printf("Couldn't execute LUA Script %s/n", lua_tostring(ls, -1));		lua_close(ls);		return(LUAREST_ERROR);    }	lua_getglobal(ls, "luarest_init");    if (lua_isfunction(ls, -1) == 0) {		printf("Couln'd find 'luarest_init' table in LUA script!/n");		lua_close(ls);		return(LUAREST_ERROR);	}	app = (application*)lua_newuserdata(ls, sizeof(application));	luaL_getmetatable(ls, LUA_USERDATA_APPLICATION);	lua_setmetatable(ls, -2);	app->s = NULL;	utstring_new(app->name);	utstring_printf(app->name, appName);	if (lua_pcall(ls, 1, 0, 0) != 0) {		printf("Error calling luarest_init: %s/n!", lua_tostring(ls, -1));		lua_close(ls);		return(LUAREST_ERROR);	}	app->lua_state = ls;	HASH_ADD_KEYPTR(hh, *apps, utstring_body(app->name), utstring_len(app->name), app);	return(LUAREST_SUCCESS);}
开发者ID:stoni,项目名称:luarest,代码行数:42,


示例24: Sinproc_socket_bound_add_conn

void Sinproc_socket_bound_add_conn(nitro_inproc_socket_t *b,                                   nitro_inproc_socket_t *c) {    pthread_rwlock_wrlock(&b->link_lock);    HASH_ADD_KEYPTR(bound_hh,                    b->registry, c->opt->ident,                    SOCKET_IDENT_LENGTH, c);    CDL_PREPEND(b->links, c);    ++b->num_links;    if (!b->current) {        b->current = c;    }    c->links = b;    nitro_counted_buffer_incref(b->bind_counter);    pthread_rwlock_unlock(&b->link_lock);}
开发者ID:bumptech,项目名称:nitro,代码行数:20,


示例25: register_creature_type

int register_creature_type(const char *id, const char *name, const char *desc,                           enum sprite_ids sprite_id) {    struct CreatureType *new_type;    HASH_FIND(hh, creature_list, id, strlen(id), new_type);    if (new_type == NULL) {        DEBUG("registering new creature type with id %s/n", id);        new_type = (struct CreatureType *)malloc(sizeof(struct CreatureType));        new_type->creature_type_id = strdup(id);        new_type->description = strdup(desc);        new_type->name = strdup(name);        new_type->sprite_id = sprite_id;        HASH_ADD_KEYPTR(hh, creature_list, id, strlen(id), new_type);    } else {        ERROR("Attempted to register duplicate creature type %s/n", id);        return -1;    }    return 0;}
开发者ID:not-napoleon,项目名称:Kookooligit,代码行数:20,


示例26: plugin_register

static intplugin_register(const char *key, prc_plugin_cmd_t *func){  plugin_ht_t *item, *_item;  item = malloc(sizeof(plugin_ht_t));  item->func = func;  _item = item;  HASH_ADD_KEYPTR(hh, plugin_head, key, strlen(key), item);  HASH_FIND(hh, plugin_head, key, strlen(key), item);  if (!item) {    free(_item);    return -1;  }  return 0;}
开发者ID:buhman,项目名称:prc,代码行数:20,


示例27: sol_event_listener_add

void sol_event_listener_add(SolObject object, char* type, SolFunction callback) {    listener_count++;    struct sol_event_listener* new_listener;    // check if already exists    HASH_FIND_STR(object->listeners, type, new_listener);    if (new_listener == NULL) {        new_listener = malloc(sizeof(*new_listener));        new_listener->type = strdup(type);        new_listener->listeners = NULL;        HASH_ADD_KEYPTR(hh, object->listeners, new_listener->type, strlen(new_listener->type), new_listener);    }    if (new_listener->listeners == NULL) {        new_listener->listeners = new_listener->listeners_end = malloc(sizeof(*new_listener->listeners_end));    } else {        new_listener->listeners_end->next = malloc(sizeof(*new_listener->listeners_end));        new_listener->listeners_end = new_listener->listeners_end->next;    }    new_listener->listeners_end->callback = (SolFunction) sol_obj_retain((SolObject) callback);    new_listener->listeners_end->next = NULL;}
开发者ID:lexi-lambda,项目名称:libsol,代码行数:20,


示例28: add_to_cache

void add_to_cache(char *key, char *value){    struct CacheEntry *entry, *tmp_entry;    entry = malloc(sizeof(struct CacheEntry));    entry->key = strdup(key);    entry->value = strdup(value);    HASH_ADD_KEYPTR(hh, cache, entry->key, strlen(entry->key), entry);        // prune the cache to MAX_CACHE_SIZE    if (HASH_COUNT(cache) >= MAX_CACHE_SIZE) {        while (HASH_ITER(hh, cache, entry, tmp_entry)) {            // prune the first entry (loop is based on insertion order so this deletes the oldest item)            HASH_DELETE(hh, cache, entry);            free(entry->key);            free(entry->value);            free(entry);            break;        }    }}
开发者ID:bugcy013,项目名称:pgstatmib,代码行数:20,


示例29: ara_maintainroute_pant

/** Send PANT for route maintenance * * Send a (Periodic) ANT if a packet was received from a dst the host has not sent a packet * to for ara_pant_interval seconds. */int ara_maintainroute_pant(dessert_msg_t* msg, size_t len, dessert_msg_proc_t* proc, dessert_meshif_t* iface_in, dessert_frameid_t id) {    ara_proc_t* ap = ara_proc_get(proc);    assert(ap != 0);    // a value of zero disables PANTs    if(ara_pant_interval == 0       || !(ap->flags & proc->lflags & DESSERT_RX_FLAG_L25_DST)) {        return DESSERT_MSG_KEEP;    }    struct timeval now;    ara_usage_t* last;    gettimeofday(&now, NULL);    pthread_rwlock_rdlock(&ullock);    HASH_FIND(hh, ut, &(ap->src), sizeof(ara_address_t), last);    if(last == NULL) {        last = malloc(sizeof(ara_usage_t));        memcpy(&(last->dst), &(ap->src), sizeof(ara_address_t));        HASH_ADD_KEYPTR(hh, ut, &(last->dst), sizeof(ara_address_t), last);        last->t.tv_sec = 0;        last->t.tv_usec = 0;    }    /* need to send pant ?*/    if((last->t.tv_sec) + ara_pant_interval < now.tv_sec) {        last->t.tv_sec = now.tv_sec;        last->t.tv_usec = now.tv_usec;        _ara_sendbant(ap->src);        dessert_info("the last BANT was a PANT");    }    pthread_rwlock_unlock(&ullock);    return DESSERT_MSG_KEEP;}
开发者ID:Dekue,项目名称:des-routing-algorithms,代码行数:46,



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


C++ HASH_ADD_STR函数代码示例
C++ HASH_ADD_INT函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。